Is something wrong with the compiler ?

Larry Jones scjones at thor.UUCP
Sat Sep 29 07:53:35 AEST 1990


In article <BURLEY.90Sep27013312 at world.std.com>, burley at world.std.com (James C Burley) writes:
>    >	      a = ( int )(( unsigned ) ( a = ~0 ) >> 1 ));
> 
> Hmm, I thought it was ok -- doesn't "=" serve as a "sequence point" or
> some such thing, and since the lhs of the outer = is so simple it can't
> be "evaluated" before the rhs has been, and the rhs contains the other
> =, one is guaranteed the latter = is performed before the former, right?

No, '=' is not a sequence point.  The question in this case is not when
the lhs gets evaluated, but when the actual storage of the rhs into the
lhs is done.  A compiler would be completely within its rights to store
the final result into a and then overwrite it with ~0.
----
Larry Jones                         UUCP: uunet!sdrc!thor!scjones
SDRC                                      scjones at thor.UUCP
2000 Eastman Dr.                    BIX:  ltl
Milford, OH  45150-2789             AT&T: (513) 576-2070
Yep, we'd probably be dead by now if it wasn't for Twinkies. -- Calvin



More information about the Comp.lang.c mailing list