Full name of submitter (unless configured in github; will be published with the issue): Jim X
[intro.execution] 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.
Consider this example:
#include <chrono>
int main(){
volatile int v = 0;
v = 1; // #0
std::this_thread::sleep_for(std::chrono::milliseconds(50000)); // #1
v = 2; // #2
}
The effect of #1 is
Blocks the calling thread for the relative timeout ([thread.req.timing]) specified by rel_time.
sleep_for, according to its specification, is not an observable behavior itself according to the definition of observable behavior. However, the access to the volatile glvalue is an observable behavior. The current wording only requires a conforming implementation to evaluate them strictly according to the abstract machine's rules. Does this rule only involve visibility, and must every evaluation be preserved?
In other words, can a conforming implementation eliminate the call to sleep_for according to the "as-if" rule? The current wording, "are evaluated strictly according to the rules of the abstract machine", is not very clear about this point.
Full name of submitter (unless configured in github; will be published with the issue): Jim X
[intro.execution] p8 says:
Consider this example:
The effect of
#1issleep_for, according to its specification, is not an observable behavior itself according to the definition of observable behavior. However, the access to the volatile glvalue is an observable behavior. The current wording only requires a conforming implementation to evaluate them strictly according to the abstract machine's rules. Does this rule only involve visibility, and must every evaluation be preserved?In other words, can a conforming implementation eliminate the call to
sleep_foraccording to the "as-if" rule? The current wording, "are evaluated strictly according to the rules of the abstract machine", is not very clear about this point.