Expression sequencing query

SA User Serv. eectrsef at titan.UUCP
Sat Sep 20 04:54:27 AEST 1986

In article <760 at oakhill.UUCP> tomc at oakhill.UUCP (Tom Cunningham) writes:
>	/* a = b + b + b */
>	a = ((b=1),b) + ((b=2),b) + ((b=3),b)
>I expected the result to be 6.  With the Microsoft C compiler and the
>compiler on the Sun 3, the result is 9.  Apparently the parenthetical
>assignments are all getting done before the comma and addition.  Any
>thoughts on this?
Tom, I agree, the result should be 6, as defined by K&R, but I have tried
it on a Cyber 180/830 running NOS VE, and get 9, also AT&T's 3B5
System V, gets 9, But A copy of the Small-C Compiler that I have ported
comes up with a 6.  Does this seam to imply that Small-C is a better
(more accurate) compiler, than those that AT&T produces?  I find it
totally unaccepable that AT&T can not produce a working C compiler.
I would like everyone to test it on as many machines as prossible, to
see if we can find as least ONE other besides Small-C, that works.

Mike Stump  ucbvax!hplabs!csun!csunb!beusemrs

More information about the Comp.lang.c mailing list