DEFINITE bug in Turbo C 2.0 (WHO'S GOT THE BUG????)

Reino de Boer reino at cs.eur.nl
Fri Mar 23 17:39:23 AEST 1990


karl at haddock.ima.isc.com (Karl Heuer) writes:

>>[Several other compilers give still different results]
>>WHO'S GOT THE BUG?????

>The author of the code.

I think the point made was not that the results should be the same, but
that the following code

#define f(a) a*a

int a, x;
a = 10;
x = f( ++a );

should either compute
r1 = ++a;
r2 = ++r1;
x = r1 * r2;
or
r2 = ++a;
r1 = ++r2;
x = r1 * r2;
in which case both computations leave (11 * 12) in "x".

Now, this all depends on the relative precedence of "++" and "*", and
that is all it should depend on.
To my knowledge the unary operators have priority below the primary
operators, but higher than any other binary operator.

Please correct me if I'm wrong, Reino

-- 
Reino R. A. de Boer     "We want to build the right product right, right?"
Erasmus University Rotterdam ( Informatica )
e-mail: reino at cs.eur.nl



More information about the Comp.lang.c mailing list