Operator priority determines how the operands are grouped together to calculate the result. This does not necessarily determine the use of side effects.
In C ++, ++ operators will both be evaluated before the + operator (although this only makes a difference in ++x , because the value of x++ same as x ). The side effect of incrementing x occurs up to the next point of the sequence in C ++ and that all we can say is the only point of the sequence in this expression after a complete evaluation, including purpose. In addition, the result of modifying an object more than once between points in a sequence is clearly undefined in accordance with the standard.
Given undefined behavior, a typical implementation will do something that depends on the details of how certain implementation sequences determine the behavior, and therefore you often get consistent results if you stick to the same version of a single compiler.
David thornley
source share