Article View: comp.std.c
Article #573No sequence points in assignment
From: Tom Karzes
Date: Tue, 12 Sep 1989 19:22
Date: Tue, 12 Sep 1989 19:22
19 lines
1471 bytes
1471 bytes
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"?
Technical Details
Message-ID:
<1021@m3.mfci.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!yale!mfci!karzesShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!yale!mfci!karzes From: karzes@mfci.UUCP (Tom Karzes) Newsgroups: comp.std.c Subject: No sequence points in assignment Message-ID: <1021@m3.mfci.UUCP> Date: 12 Sep 89 19:22:49 GMT Sender: karzes@mfci.UUCP Reply-To: karzes@mfci.UUCP (Tom Karzes) Distribution: comp Organization: Multiflow Computer Inc., Branford Ct. 06405 Lines: 19