A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cplusplus.github.io/LWG/issue4309 below:

How are two seq_cst operations ordered in the single total order if these two operations are unsequenced?

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.

4309. How are two 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_cst operations, including fences, that satisfies the following constraints.

Then, it says that:

First, if A and B are memory_order::seq_cst operations 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?

Suggested Resolution: We may want to say the order of such operations is indeterminate in the single total order. That is, either A precedes B or B precedes A, but it is unspecified which.

Proposed resolution:


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4