It is due to the definition of the conditional operator and its priority.
The conditional operator is defined as
conditional-expression:
logical-or-expression
logical-or-expression ? expression : assignment-expression
The assignment operator has higher priority compared with the comma operator
So your expression is equivalent to
(( x > 10 && y > 10 ) ? ++x, ++y : --x ), --y;
Last edited on
@vlad thanks again. I find that a bit bizzare though considering I parenthesized the condition before the ?.
In my example there was a typo. The condition should be enclosed in parentheses.:)
Hah, likewise! Thanks for the explanation :)