Hi,


Why does the following code exhibit undefined behavior?
Code:
int i = 1;
i += ++i;

Is it because of the following rule?
Between consecutive "sequence points" an object's value can be modified only once by an expression.

I think that it shouldn't be undefined, because:
1) Since ++ has higher precedence than +=, the increment operator is first evaluated. So ++i increments i by one and returns the new value of i, that is 2.
2) Then += is evaluated. The left operand is an object (having number 2) and the right operand is 2. So the sum, of the content of the object and two, is finally stored in the object (that is i).


It's however true that the object's value is modified more than once between the two consecutive sequence points.


Thanks for help...