Sequence of Evaluation: a = ((b=1),b) + ((b=2),b) + ((b=3),b);

Joshua W. Knight JOSH at ibm-sj.ARPA
Wed Oct 8 06:20:18 AEST 1986


This has been thoroughly discussed, so let me just point out the part
of the minutes of the June 1986 meeting of the ANSI C standards group
that makes me believe that the current standard MAY require the value
6 (I wasn't clear earlier).  In addition to providing that comma
operators are sequence points, it appears to me to be required that
the evaluation of an expression whose top operator is an operator
with a sequence point not be interleaved with other evaluations.
I wasn't at the meeting (haven't been to any) and I haven't seen the
latest version of the draft standard.

I point out (just to be contentious ;-) that while a Harbison was at
the June 1986 meeting of the ANSI C standards group, there was neither
a Kernighan nor a Ritchie there.

Also, as if the whole mess wasn't ambiguous enough already, I encourage
those who find that a compiler/optimization level gets a=6, (and a lower
optimization level does not), to change the 2 to a 3 and the 3 to a 7 to
make sure that it doesn't then get 9 instead of 11.  I.e. to make sure
that it is not just moving around the 3 assignment operations still
*before* the rest of the expression.  After all 6 = 1+2+3 = 2+2+2 ;-)

Of course, I speak only for myself, not for my employer.

			Josh Knight
			IBM T.J. Watson Research Center
josh at ibm.com, josh at yktvmh.BITNET



More information about the Comp.lang.c mailing list