Short circuit evaluation/expression rearrangement (2nd summary)

Doug Gwyn gwyn at smoke.brl.mil
Tue May 28 20:02:25 AEST 1991


In article <1991May27.113628.26880 at ucthpx.uct.ac.za> gram at uctcs.uucp (Graham Wheeler) writes:
>From: worley at compass.COM
>... in "a + b + c",
>the first addition must be performed before the second, because it
>associates as "(a + b) + c", showing that the second addition has as
>an argument the result of the first.

The above is incorrect.  A conforming implementation is obliged to
perform the operations so that it doesn't create an exception where
one would not have occurred in evaluating the expression strictly
according to the precedence implied by the grammar, but within
those constraints it may perform the additions in any order.  To
force an order of evaluation (in Standard C), you must use parentheses.



More information about the Comp.lang.c mailing list