conditional expression evaluation

Rick Genter rgenter at j.bbn.com
Thu Jan 15 20:21:14 AEST 1987


> The
> other example with the *cp++'s was subtle and at worst confusing.

Not only that, but it was outright wrong.  Since the only guarantee on ++
is that it will be evaluated before the start of the next statement, the
compiler is free to implement the expression as:

	if ( (booltemp = *cp | *cp | *cp, cp += 3, booltemp) ) {
		...
	}

or, alternatively,

	if ( (cp += 3, *cp | *cp | *cp) ) {
		...
	}

or any other combination or permutation of increment and dereference.  The
only way to be safe is to never have the same object undergo two side effects
in the same statement/expression.
					- Rick
--------
Rick Genter 				BBN Laboratories Inc.
(617) 497-3848				10 Moulton St.  6/512
rgenter at bbn.COM  (Internet new)		Cambridge, MA   02238
rgenter at bbnj.ARPA (Internet old)	seismo!bbn.com!rgenter (UUCP)



More information about the Comp.lang.c mailing list