expression sequencing bugs

Gunnar Stefansson gunnar at hafro.UUCP
Fri Oct 3 17:08:30 AEST 1986

In article <4197 at brl-smoke.ARPA> C90630JG%WUVMD.BITNET at wiscvm.ARPA writes:
>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 ......................
>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.

Just for the record, our HP 9000, Model 550 running HP-UX returns
the value 6. Surely anything else isn't just strange, bizarre,..., but
just plain a compiler bug.


More information about the Comp.lang.c mailing list