C question

VLD/VMB gwyn at Brl-Vld.ARPA
Thu Apr 11 04:01:38 AEST 1985

A more useful question might be, "What does the draft proposed ANSI C
standard say about
	x = x++;
?"  The X3J11 committee has attempted to deal with such issues by
identifying what constitutes a "side effect" (post-increment is one)
and when side effects must be enforced during execution (at "sequence
points").  Assignment is NOT flagged as a sequence point; I don't
know whether this was intentional but I suspect it was.  The ";" of
an expression-statement causes the expression to be evaluated for its
side effects, though.

The upshot is that the result is implementation-dependent.  In general,
one is asking for trouble any time he modifies AND uses an object in
different places in the same expression, even if the behavior is
supposed to be well-defined.  I have yet to see a compiler that wouldn't
break if pushed too hard.

More information about the Comp.lang.c mailing list