The C11 standard (ISO/IEC 9899:2011) has introduced a new definition of side effect sequencing within an expression (see related question). The se
But why is
i = ++i + 1undefined according to C11's terminology?
C11 says that the side effect on left i is sequenced but not the value computations (evaluations) of left and right i.
It is obvious that the side effect on LHS will take place after the evaluation of expressions on LHS and RHS.
To explain this a better example could be
int i = 1;
i = i++ + 3;
(First let's assume that this example will not invoke UB). Now the final value of i could be 4 or 2.
Case 1.
Left i is fetched and then it is incremented and 3 is added to it and finally 4 is assigned to i.
Case 2.
Left i is fetched and then 3 is added to it and then 4 is assigned to i and finally i is incremented. In this case the final value of i is 2.
Although the side effect on left i is sequenced the final value stored to i is not defined, i.e it is not necessarily by the assignment and hence the side effect on i is unsequenced.