Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!elroy.jpl.nasa.gov!decwrl!pa.dec.com!bacchus!mwm From: mwm@pa.dec.com (Mike (My Watch Has Windows) Meyer) Newsgroups: comp.sys.amiga.programmer Subject: Re: Compiler code (was a flame fest) (now a lesser flame fest) Message-ID: Date: 25 Apr 91 15:36:11 GMT References: <1991Apr17.180342.25312@engin.umich.edu> <91112.093750GHGAQZ4@cc1.kuleuven.ac.be> Sender: news@pa.dec.com (News) Organization: Missionaria Phonibalonica Lines: 27 In-Reply-To: dillon@overload.Berkeley.CA.US's message of 23 Apr 91 21:01:52 GMT In article dillon@overload.Berkeley.CA.US (Matthew Dillon) writes: The ONLY three C operators that guarentee evaluation order are &&, ||, and the comma as an operator (when not used in a subroutine call, where it doesn't act as the comma operator). Don't forget ?:. It is (they are?) a trinary operator, and guarantees that the leftmost operand is evaluated first, then only one of the other two is evaluated. ++a + ++a If a is 1, the result can be 2 + 2 or 2 + 3 or 3 + 2 and at the end 'a' can be either 3 or 4 depending on how the compiler was designed. Actually, ANSI says the result is "undefined". Normally, you'll get one of the things you mentioned or 3 + 3, but there are oddball compilers out there that completely unexpected things. The bottom line is still the same - you don't want to do this kind of thing.