This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Tentatively NAD status.
seq_cst operations ordered in the single total order if these two operations are unsequenced?Section: 32.5.4 [atomics.order] Status: Tentatively NAD Submitter: jim x Opened: 2025-08-06 Last modified: 2025-10-23
Priority: Not Prioritized
View other active issues in [atomics.order].
View all other issues in [atomics.order].
View all issues with Tentatively NAD status.
Discussion:
Consider this snippet code:
std::atomic<int> flag = {0};
std::atomic<int> turn = {0};
if(flag + turn){}
The loads of flag and turn as the operands of + are unsequenced according to [intro.execution] p10.
Except where noted, evaluations of operands of individual operators and of subexpressions of individual expressions are unsequenced.
However, 32.5.4 [atomics.order] p4 says:
There is a single total order S on all
memory_order::seq_cstoperations, including fences, that satisfies the following constraints.
Then, it says that:
First, if A and B are
memory_order::seq_cstoperations and A strongly happens before B, then A precedes B in S.
According to the first sentence, the load of flag and the load of turn do have an order in the single
total order S since they are both memory_order::seq_cst operations. However, since they are unsequenced,
the second sentence does not apply to them. So, what's the order of them in S? Is the order of them in
S unspecified?
[2025-10-23; Reflector poll; Status changed: New → Tentatively NAD.]
The loads are both done within functions calls, so are at worst indeterminately sequenced. So we already say what the suggested resolution wants.
Proposed resolution: