Operator precedence governs how operands are grouped together for calculating the result. It doesn't necessarily govern the order of applying side effects.
In C++, the ++
operators will both be calculated before the +
operator (although this only makes a difference in the ++x
, because the value of x++
is the same as x
). The side effect of incrementing x
happens before the next sequence point in C++, and that's all we can say, and the only sequence point in that expression is after it is completely evaluated, including the assignment. Further, the result of modifying an object more than once between sequence points is explicitly undefined according to the Standard.
Given undefined behavior, the typical implementation will do something that depends on the details of how the implementation sequences defined behavior, and so you will often get a consistent result if you stick to one version of one compiler.