Why was this statement in C99 changed in C11?

Viewed 278

C99 Standard:

Between the previous and next sequence point an object shall have its stored value modified at most once by the evaluation of an expression

C11 Standard:

If a side effect on a scalar object is unsequenced relative to another side effect on the same scalar object, the behavior is undefined.

So was this definition by the C99 standard incomplete and hence it was updated in C11 since it only contains the term object and not scalar object?

1 Answers

This is because C11 attempted to cover multi-threading/parallel execution. The fundamental rules of program execution in the "abstract machine" added this cumbersome text between C99 and C11 (C11 5.1.2.3/3):

Sequenced before is an asymmetric, transitive, pair-wise relation between evaluations executed by a single thread, which induces a partial order among those evaluations. Given any two evaluations A and B, if A is sequenced before B, then the execution of A shall precede the execution of B. (Conversely, if A is sequenced before B, then B is sequenced after A.) If A is not sequenced before or after B, then A and B are unsequenced. Evaluations A and B are indeterminately sequenced when A is sequenced either before or after B, but it is unspecified which.13) The presence of a sequence point between the evaluation of expressions A and B implies that every value computation and side effect associated with A is sequenced before every value computation and side effect associated with B. (A summary of the sequence points is given in annex C.)

Therefore the part you quote (C99 6.5/2) was changed accordingly, to suit the definition of program execution in the abstract machine, which supposedly now also covers parallel execution. Unfortunately - since the C99 text was so much more readable. Technically, nothing changed at all, if you don't consider parallel execution. The rules about sequence points from C99 still apply, it's just a different wording. This change also meant to synchronize C11 with C++11 which has similar rules.

Related