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

Geoffrey Rogers grogers at convex.com
Wed Mar 28 06:04:54 AEST 1990


In article <16269 at haddock.ima.isc.com> karl at haddock.ima.isc.com (Karl Heuer) writes:
>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.

I agree with Karl, it is not the compilers that are in error here, it is
the code. Also as a side note: x = ++a * ++a; is not ANSI C compliant.
The reason it is not, is because you are modifing the same object more then
once in the same expression.

cheers

+------------------------------------+---------------------------------+
| Geoffrey C. Rogers   		     | "Whose brain did you get?"      |
| grogers at convex.com                 | "Abbie Normal!"                 |
| {sun,uunet,uiucdcs}!convex!grogers |                                 |
+------------------------------------+---------------------------------+



More information about the Comp.lang.c mailing list