79804530

Date: 2025-10-30 08:34:32
Score: 2
Natty:
Report link

If you want a language lawyer-style answer:

As said in [intro.abstract]/p1:

The semantic descriptions in this document define a parameterized nondeterministic abstract machine. This document 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. 6

The footnote 6 says that the above is the so called "as-if" rule:

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.

That said, the implementation only needs to make sure the observable behavior is correct. Look at [intro.abstract]/p6:

The least requirements on a conforming implementation are:

  • Accesses through volatile glvalues are evaluated strictly according to the rules of the abstract machine.
  • At program termination, all data written into files shall be identical to one of the possible results that execution of the program according to the abstract semantics would have produced.
  • The input and output dynamics of interactive devices shall take place in such a fashion that prompting output is actually delivered before a program waits for input. What constitutes an interactive device is implementation-defined.

These collectively are referred to as the observable behavior of the program.

[Note 2 : More stringent correspondences between abstract and actual semantics can be defined by each implementation. — end note]

That's the definition of "observable behavior". The difference produced by the StoreStore optimization you described does not fall into any of these categories.

Reasons:
  • Blacklisted phrase (1): this document
  • Blacklisted phrase (1): This document
  • Long answer (-1):
  • No code block (0.5):
  • Low reputation (0.5):
Posted by: GKxx