Expression sequencing query

Tom Cunningham tomc at oakhill.UUCP
Sat Sep 6 08:16:30 AEST 1986


Sorry if this topic has been overly exercised already.  In the following
code fragment:

	/* 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 thi

Tom Cunningham     "Good, fast, cheap -- select two."
USPS:  Motorola Inc.  6501 William Cannon Dr. W.  Austin, TX 78735-8598
UUCP:  {ihnp4,seismo,ctvax,gatech}!ut-sally!oakhill!tomc
Phone: 512-440-2953



More information about the Comp.lang.c mailing list