This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of New status.
Section: 30.7.7 [time.clock.steady] Status: New Submitter: jim x Opened: 2026-11-23 Last modified: 2026-11-27
Priority: Not Prioritized
View all issues with New status.
Discussion:
According to 30.7.7 [time.clock.steady] p1:
Objects of class
steady_clockrepresent clocks for which values oftime_pointnever decrease as physical time advances and for which values oftime_pointadvance at a steady rate relative to real time. That is, the clock may not be adjusted.
And 30.3 [time.clock.req] p2 specifies:
C1::now(): Returns atime_pointobject representing the current point in time.
Furthermore, 6.10.1 [intro.execution] p8 and 8.1 [stmt.pre] p1 define the intra-thread evaluation order:
If A is sequenced before B (or, equivalently, B is sequenced after A), then the execution of A shall precede the execution of B.
Except as indicated, statements are executed in sequence (6.10.1 [intro.execution]).
Now consider the following example:
#include <thread>
#include <atomic>
#include <chrono>
#include <iostream>
int main() {
std::chrono::steady_clock::time_point c1, c2;
int read = 0;
std::atomic<int> val = 0;
std::thread t1([&]() {
val.store(1, std::memory_order::relaxed); // #0
c1 = std::chrono::steady_clock::now(); // #1
});
std::thread t2([&]() {
c2 = std::chrono::steady_clock::now(); // #2
read = val.load(std::memory_order::relaxed); // #3
});
t1.join();
t2.join();
if (c1 < c2) {
std::cout << read;
}
}
Suppose the execution yields c1 < c2. From the perspective of the abstract machine:
In thread t1, #0 is sequenced before #1. By 6.10.1 [intro.execution] p8, the evaluation
of #0 precedes #1. Since #1 observes a point in physical time c1, #0 is executed no later
than physical time c1.
Similarly, in thread t2, #2 is sequenced before #3. The evaluation of #2 precedes #3.
Since #2 observes physical time c2, #3 is executed no earlier than physical time c2.
Given c1 < c2, this establishes an apparent temporal order in physical time:
#0 <= c1 < c2 <= #3.
However, from the standpoint of the memory model (6.10.2 [intro.multithread]):
There is no synchronizes-with relationship between t1 and t2 (relaxed operations do not synchronize).
Consequently, #0 does not happen before #3.
Therefore, the memory model permits #3 to observe read == 0.
This exposes a fundamental tension: Does the physical timeline observed via now()
imply any execution in temporal order across threads within the abstract machine?
Specifically: Does the observation c1 < c2 combined with read == 0 mean
that the abstract machine formally permits measuring "inter-thread store-to-load visibility latency"?
<chrono>, but fails to formally integrate it into the execution model.
The standard currently makes physical time observable through std::chrono::steady_clock::now(),
but fails to specify the semantics of such observations in conjunction with the control
flow/memory order. It is completely vague whether sampling real time allows programmers to reason
about the temporal ordering of evaluations across threads. Clarification is requested to bridge the
gap between 30.7 [time.clock] and the abstract machine's control flow.
Suggested resolution:
I suggest explicitly specifying that the value returned bynow() does not participate in any
relationships implied by control flow, nor can it be used to deduce any partial ordering in physical
time regarding the execution of surrounding evaluations.
Proposed resolution: