[intro.abstract] p8 says:
The following specify the observable behavior of the program:
- Accesses through volatile glvalues are evaluated strictly according to the rules of the abstract machine.
- Data is delivered to the host environment to be written into files (See also: ISO/IEC 9899:2024, 7.23.3).
- 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.
This is an exhaustive list, which means that things not specified in the list are not considered observable behavior.
Consider this example:
int main(){
auto t = network_request(); // #1
}
First, calling the IO library has side effects as per [intro.execution] p7:
Reading an object designated by a volatile glvalue ([basic.lval]), modifying an object, producing an injected declaration ([expr.const]), calling a library I/O function, or calling a function that does any of those operations are all side effects
however, side effects are not observable behavior because it is not in the list. So, does it mean a conforming implementation can eliminate the calling to network_request under the "as-if" rule? That is, the whole program is a no-op because calling IO functions not involving things listed in [intro.abstract] p8 are not observable behavior, the conforming implementation does not need to emulate the structure according to the "as-if" rule:
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.
network_request()does, and wouldn't remove it because otherwise its users would be unhappy with its vendor; or it's a black-box call into some library (e.g. provided by the OS), and then it wouldn't remove it because it cannot rule out that the call performs I/O as anticipated by the standard, or touches a volatile object or something. I mean, real conforming implementations are authored by real people who understand how their products are used in the real world.