seq_cst operations ordered in the single total order if these two operations are unsequenced?Section: 32.5.4 [atomics.order] Status: New Submitter: jim x Opened: 2025-08-06 Last modified: 2025-08-09
Priority: Not Prioritized
View other active issues in [atomics.order].
View all other issues in [atomics.order].
View all issues with New 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?
Proposed resolution: