Will i=i++ be newly well-defined in C17?
The full story. In C99 we had this text for 6.5.16 the assignment operator:
The side effect of updating the stored value of the left operand shall occur between the previous and the next sequence point.
The order of evaluation of the operands is unspecified. If an attempt is made to modify the result of an assignment operator or to access it after the next sequence point, the behavior is undefined.
This was changed in C11 to:
The side effect of updating the stored value of the left operand is sequenced after the value computations of the left and right operands. The evaluations of the operands are unsequenced.
This is just different (and worse) wording, the two versions behave the same - the key being the last sentence in the C11 part which still makes this undefined behavior, since evaluation of the left operand is still unsequenced in relation to the right operand. Value computation just refers to the individual operands.
C17 has identical text as C11. So the answer is: no, i = i++;
is still undefined behavior in C17.
Just for reference, compare this with C++11 (5.17):
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.
This is roughly the same text as C11, without the explicit "the evaluations of the operands are unsequenced". This was a flaw in C++11, it isn't clear if this would make certain expressions well-defined or not.
C++17 provides a clarification (8.5.18):
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. The right operand is sequenced before the left operand.
So in C++17, i=i++;
is definitely well-defined. And as we can see, the wording is explicit, as opposed to "unsequenced" in C11/C17.
The passage you highlighted only says that the expressions i++
and i
are evaluated before the evaluation of the full expression i = i++
. It is still undefined behavior because i
is being modified more than once in an expression without a sequence point.
That passage first appeared in C11, so there's no change from that version C17.