-
Notifications
You must be signed in to change notification settings - Fork 8
Description
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[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 that specifies which are observable behaviors. In other words, the stuff not in the list can be eliminated by a conforming implementation as per the "as-if" rule.
Consider this example:
bool network_request(char const *);
int main(){
network_request("hello");
}If the external function network_request was written in, for example, assembly, in which world, there is certainly no "object", let alone a volatile object, and anything is either a register, a memory address, an interrupt, or so on. In this case, a conforming implementation can eliminate the call to network_request because it touches nothing that is specified as observable behavior from the perspective of the C++ standard.
If the external function was originally written in C++, however, its definition does not appear in the translation unit of the current program that uses it, the implementation knows nothing about this black box function; it's vague to say whether the network_request has an observable behavior or not. Generally, the burden of proof is on the side that says it exists. If the implementation cannot prove the black box network_request has observable behavior, then it does not have, as per Russell's Teapot.
Suggested Resolution
[intro.abstract] p8 seems to need to give implementations a chance that define extra observable behaviors; these observable behaviors are not anticipated by the standard. For example, network requests, database modifications, interruptions, which affect the real-world behavior