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.

4645. Clarify how physical time observations relate to abstract machine execution

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_clock represent clocks for which values of time_point never decrease as physical time advances and for which values of time_point advance 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 a time_point object 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:

  1. 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.

  2. 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.

  3. 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]):

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"?

Currently, the standard treats real/physical time as an external concept that is observable via <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 by now() 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: