The evaluation order of short-circuit operators (||
and &&
) is guaranteed by the standard to be left to right (otherwise they would lose part of their usefulness).
§6.5.13 ¶4
Unlike the bitwise binary &
operator, the &&
operator guarantees left-to-right evaluation;
there is a sequence point after the evaluation of the first operand. If the first operand
compares equal to 0
, the second operand is not evaluated.
§6.5.14 ¶4
Unlike the bitwise |
operator, the ||
operator guarantees left-to-right evaluation; there is
a sequence point after the evaluation of the first operand. If the first operand compares
unequal to 0, the second operand is not evaluated.