A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/cplusplus/CWG/issues/641 below:

LWG4174 [atomics.order] p3.3 The initialization to an atomic object is not a atomic operation · Issue #641 · cplusplus/CWG · GitHub

Full name of submitter (unless configured in github; will be published with the issue): Jim X

Consider this example:

std::atomic<int> v = 0;
// thread 1:
v.load(std::memory_order::seq_cst);
//thread 2:
v.store(1,std::memory_order::seq_cst);

If the load operation reads the value 0, how are they ordered in the single total order? According to [atomics.order] p3

An atomic operation A on some atomic object M is coherence-ordered before another atomic operation B on M if

The initialization to v is not an atomic modification as per [atomics.types.operations] p3

Effects: Initializes the object with the value desired. Initialization is not an atomic operation ([intro.multithread]).

The initialization(i.e. X) precedes the store(i.e. B) in the modification order of v, however, X is not atomic modification, so, how does p3.3 apply to this case to determine the order of the load and store in the single total order?


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