Let's just take for example the specific compound assignment operator ^=
. This stackoverflow page says modification of the left operand may have not been done after the evaluation of ^=
, and thus making the code a ^= b ^= a ^= b
undefined behaivor. But this does not seem to be the case. The standard says in 5.17 [expr.ass] that
In all cases, the assignment is sequenced after the value computation of the right and left operands, and before the value computation of the assignment expression.
There are two keypoints in this statement. 1) What does the subject assignment refers to? In my opinion, it refers just to the modification of the left operand. 2) What does value computation of the assignment expression refers to? cppreference says it refers to returning the reference to the modified object (emphasis mine).
As a conclusion, the left operand should have already been modified after the evaluation of ^=
, which is a contradiction to what (most) people think. Am I missing something here?