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

Karl Heuer karl at haddock.ima.isc.com
Sat Mar 24 07:35:00 AEST 1990


In article <1990Mar23.073923.6425 at cs.eur.nl> reino at cs.eur.nl (Reino de Boer) writes:
>Now, this all depends on the relative precedence of "++" and "*", and
>that is all it should depend on.  Please correct me if I'm wrong

You're wrong.  For example, another valid computation of "x = ++a * ++a" is
"r1 = a+1; r2 = a+1; x = r1*r2; ++a; ++a;".  The only constraint on the timing
of side effects is that they must take place after the previous sequence point
and before the next one.

The bottom line is: that code does not produce a well-defined result.  Don't
write code like that.

Karl W. Z. Heuer (karl at ima.ima.isc.com or harvard!ima!karl), The Walking Lint



More information about the Comp.lang.c mailing list