if this legal code?

Lloyd Kremer kremer at cs.odu.edu
Wed Jun 26 22:23:46 AEST 1991


In article <1991Jun25.235904.23103 at netcom.COM> aed at netcom.COM (Andrew Davidson) writes:
>
>if (! ((tt = testEntry.code - testCode) || (tt = testEntry.leg -
>testLeg)))
>	{
>	....
>	}
>
>does the language guarentee that if testEntry.code -testCode is not
>equal to 0, that the second assignment (tt  = testEntry.leg - testLeg)
>will not be executed?

Yes.  To compiler writers the || symbol in this statement is a sequence point
and the expression to its right may or may not be evaluated (i.e. the code to
evaluate it may or may not be executed) depending on the result of the
of the expression to its left.  (That's the way it stacks up for this
particular statement anyway.)

The code here will use the first expression if it is non-zero, else use the
second expression; but if both are zero enter the "if" block.

					Lloyd Kremer
					Hilton Systems, Inc.
					kremer at cs.odu.edu



More information about the Comp.lang.c mailing list