No sequence points in assignment

Tom Karzes karzes at mfci.UUCP
Wed Sep 13 05:22:49 AEST 1989


I have a question about assignment expressions.  According to the standard,
an assignment expression does not introduce a sequence point, although the
side effect of updating the stored value of the left operand must occur
between the previous sequence point and the next sequence point.  This
seems to imply that in an expression with multiple assignments, the actual
assignments may occur in any order provided the stored values can be
determined and the assignments all take place between the previous
sequence point and the next sequence point.  If this interpretation is
correct, it seems to me that it can lead to some counter intuitive
results.  For example, consider the following statement:

    x = a + (x = b);

Could the assignment for (x = b) be performed after the outer
assignment?  Since it knows that the value of (x = b) is b,
can't it delay the assignment of b to x?  I.e., could this
statement be validly translated as "evaluate b, evaluate a,
add, assign the result to x, assign the previous result, b,
to x"?



More information about the Comp.std.c mailing list