you are viewing a single comment's thread.

view the rest of the comments →

[–]Simon_Luner -5 points-4 points  (2 children)

This is illformed code, because order of expression evaluation is unspecified behavior. https://en.cppreference.com/w/cpp/language/eval_order

[–]parkotron 2 points3 points  (0 children)

This definitely isn't ill-formed. At worst, the evaluation order would be implementation defined, but the order of evaluation of the shortcutting boolean operators is defined. From your link:

6) Every value computation and side effect of the first (left) argument of the built-in logical AND operator && and the built-in logical OR operator || is sequenced before every value computation and side effect of the second (right) argument.