[Coco] Found strangeness in C compiler (bug)

Walter Zambotti zambotti at iinet.net.au
Tue May 21 01:32:22 EDT 2019

I have a situation where the auto post-increment was occurring first.


The increment only occurs at the wrong time when the pointer types are
double (maybe float).  So the following code works for int but not double.


int *da, *dN ; or double *da, *dN;


*da++ = *dN++ * v - *da; // this is correct as the increment should happen
after the assignment.

*da++ = *dN++ * v - *da;

*da = *dN * v - da*;


The auto post increment on the left hand side of the "=" should occur after
the assignment but it was occurring first.


So I fixed the problem by converting the code to: (this code works for all)


*da = *dN++ * v - *da; da++;  // this is correct by intention

*da = *dN++ * v - *da; da++;

*da = *dN * v - da*;


Or (this code incorrectly works for doubles and correctly fails for ints)


*da = *dN++ * v - *da++;  // this is wrong as the expression on the right
increments da before it is assigns the value to where da points.

*da = *dN++ * v - *da++;

*da = *dN * v - da*;


Ensuring the increment occurred last in order to get it working.


However when I can't duplicate the problem in an isolated example.  


Do we have the C source anywhere?



More information about the Coco mailing list