Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!elroy.jpl.nasa.gov!lll-winken!xanth!cs.odu.edu!kremer From: kremer@cs.odu.edu (Lloyd Kremer) Newsgroups: comp.lang.c Subject: Re: if this legal code? Message-ID: <1991Jun26.122346.25316@cs.odu.edu> Date: 26 Jun 91 12:23:46 GMT References: <1991Jun25.235904.23103@netcom.COM> Sender: news@cs.odu.edu (News File Owner) Organization: Old Dominion University, Norfolk, VA Lines: 24 Nntp-Posting-Host: opium.cs.odu.edu In article <1991Jun25.235904.23103@netcom.COM> aed@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@cs.odu.edu