No sequence points in assignment

Tom Karzes karzes at mfci.UUCP
Tue Sep 19 14:43:29 AEST 1989


In article <10851 at riks.csl.sony.co.jp> diamond at riks. (Norman Diamond) writes:
-In article <1026 at m3.mfci.UUCP> karzes at mfci.UUCP (Tom Karzes) quotes:
-
->The second paragraph in section 3.3 says:
->    Between the previous and next sequence point an object shall have
->    its stored value modified at most once by the evaluation of an
->    expression.  Furthermore, the prior value shall be accessed only
->    to determine the value to be stored.
-
-Even if the expression contains two assignments to the same object?
-(As did the example which led to this thread.)  Even without the
-optimizer turned on, the compiler is REQUIRED to notice and delete
-all but one assignment to the same object?
-
-(Uh, remember that other thread about whether two pointers are equal,
-and it depends on whether they point to the same object, i.e. things
-like ring numbers have to be masked out.)  Wow, a non-optimizing
-compiler is going to have to do a lot of alias checking in order to
-meet section 3.3.

This paragraph is merely describing restrictions on the side effects a
user may have in an expression.  An ANSI conforming C compiler certainly
isn't required to detect every situation in which this is violated.  It
would be nice if it could detect some of the cases at compile time, but
at best it would only be able to catch a few simple instances (most likely
involving direct scalar references).  The point is that a compiler writer
doesn't have to worry about the behavior of cases like this because they
are explicitly disallowed by the standard.



More information about the Comp.std.c mailing list