This is a problem of order of execution and it is undefined due to c++11:
5.17 Assignment and compound assignment operators
The assignment operator (=) and the compound assignment operators
all group right-to-left. All require a modifiable lvalue as their left
operand and return an lvalue referring to the left operand. The result
in all cases is a bit-field if the left operand is a bit-field. 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.
Simply put, the modification of the left argument is sequenced after the value computation, but not of the side-effects of the computation, of both sides and before returning the reference to the object.
So the actions to be taken are
A. evaluate left side ( return value of expression i++ = 0 )
B. return reference to object ( return reference to object of expression v[i++] )
C. compute side-effects for left side i.e. i-> 1
D. compute side-effects for right side i.e. i-> 2
As you can see from the rule above it is not clear if the order is ABCD
or if it should be ACBD , since the order of the side-effects computation is not defined, if it should happen first for the left side or first for the right-side.