为什么在 C11 中更改了 C99 中的此语句?
Why was this statement in C99 changed in C11?
C99 标准:
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 标准:
If a side effect on a scalar object is unsequenced relative to another side effect on the same scalar object, the behavior is undefined.
C99 标准的这个定义是否不完整,因此在 C11 中进行了更新,因为它只包含术语 object
而不是 scalar object
?
这是因为 C11 试图覆盖 multi-threading/parallel 执行。 "abstract machine"中程序执行的基本规则在C99和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.)
因此,您引用的部分 (C99 6.5/2) 已相应更改,以适应抽象机中程序执行的定义,据说现在也涵盖了并行执行。不幸的是 - 因为 C99 文本更具可读性。从技术上讲,如果您不考虑并行执行,则根本没有任何变化。 C99 中有关序列点的规则仍然适用,只是措辞不同。此更改还意味着将 C11 与具有类似规则的 C++11 同步。
C99 标准:
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 标准:
If a side effect on a scalar object is unsequenced relative to another side effect on the same scalar object, the behavior is undefined.
C99 标准的这个定义是否不完整,因此在 C11 中进行了更新,因为它只包含术语 object
而不是 scalar object
?
这是因为 C11 试图覆盖 multi-threading/parallel 执行。 "abstract machine"中程序执行的基本规则在C99和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.)
因此,您引用的部分 (C99 6.5/2) 已相应更改,以适应抽象机中程序执行的定义,据说现在也涵盖了并行执行。不幸的是 - 因为 C99 文本更具可读性。从技术上讲,如果您不考虑并行执行,则根本没有任何变化。 C99 中有关序列点的规则仍然适用,只是措辞不同。此更改还意味着将 C11 与具有类似规则的 C++11 同步。