short circuit evaluation
jpn at teddy.UUCP
jpn at teddy.UUCP
Thu Jan 29 08:36:14 AEST 1987
Why is there so much misinformation in this group?!?! I wish people who
don't know what they are talking about would not post here!
>I can find no promise in K&R that bitwise expressions are not short
>circuited even in the presence of side effects.
60 seconds with my copy of K&R yeilds this (Appendix A):
"The & operator is associative and expressions involving & may be rearranged"
"Unlike &, && guarantees left-to-right evaluation; moreover, the second
operand is not evaluated if the first operand is zero"
>In any case, I would advise not counting on full evaluation (of bitwise).
True, it is not explitly stated that & and | are not short circuited. It
also doesn't explicitly say that + and * are not short circuited! However
&& and || are EXPLICITY defined as having short circuit behavier, no other
operators are described this way, so it is safe to assume that all other
operators do NOT short-circuit.
More information about the Comp.lang.c
mailing list