C++ 标准中 "as if" 规则的声明或基础在哪里?

Where are the statement of or the foundations for the "as if" rule in the C++ Standard?

经过一些 google 搜索(例如,site:eel.is "as if rule"),我找不到在 C++ 标准中明确规定所谓的 "as if" 规则的适当位置。我所能找到的只是在调用它的标准中的那些地方,给出了 intro.execution 引用。

但是 intro.execution 似乎没有明确引用此规则的任何一般形式。我可能在这里遗漏了一些微妙的东西,但你能指出一个或多个地方,其中传达了对规则的精确规范理解吗?也许整个 intro.execution 确实是为了传达我们所谓的 "as if" 规则?我承认我只是浏览了一下。

我正在使用 this website 浏览标准的工作草案。

可以找到 "as if" 规则的定义,例如在 cppreference site 中,大意是只要满足某些约束条件,就允许编译器对程序执行转换,例如出于优化原因。

"as if" 规则的定义在 4.1.1/1 的脚注中给出。见 http://eel.is/c++draft/intro.abstract#footnote-4:

This provision is sometimes called the “as-if” rule, because an implementation is free to disregard any requirement of this document as long as the result is as if the requirement had been obeyed, as far as can be determined from the observable behavior of the program. For instance, an actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no side effects affecting the observable behavior of the program are produced.

从另一个 Draft Standard 来看,您在 link 中提到的部分实际上是 "as-if" 规则(见脚注 #5):

1.9 Program execution [intro.execution]

The semantic descriptions in this International Standard define a parameterized nondeterministic abstract machine. This International Standard places no requirement on the structure of conforming implementations. In particular, they need not copy or emulate the structure of the abstract machine. Rather, conforming implementations are required to emulate (only) the observable behavior of the abstract machine as explained below.5.
...
5) This provision is sometimes called the “as-if” rule, because an implementation is free to disregard any requirement of this International Standard as long as the result is as if the requirement had been obeyed, as far as can be determined from the observable behavior of the program. For instance, an actual implementation need not evaluate part of an expression if it can deduce that its value is not used and that no side effects affecting the observable behavior of the program are produced.

PS:我在这篇引用的文档中发现 'interesting' 的一件事是 "as-if rule":

的索引条目
program execution, 8–11
    abstract machine, 8
    as-if rule, see as-if rule