From 9a3da04cdc671060dbb23ec3ffb6b20a9fcf5881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Kr=C3=BCgler?= Date: Sun, 24 Nov 2024 12:50:53 +0100 Subject: [PATCH] New issue from jim x: "How does [atomics.order] p3 apply when then modification is an initialization?" --- xml/issue4174.xml | 56 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 xml/issue4174.xml diff --git a/xml/issue4174.xml b/xml/issue4174.xml new file mode 100644 index 0000000000..d560e3ca74 --- /dev/null +++ b/xml/issue4174.xml @@ -0,0 +1,56 @@ + + + + +How does [atomics.order] p3 apply when then modification is an initialization? +
+jim x +13 Nov 2024 +99 + + +

+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 load and store operations ordered in the single total order? +According to p3 (emphasize mine) +

+
+

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

+
    +
  1. […]

  2. +
  3. (3.3) — A and B are not the same atomic read-modify-write operation, +and there exists an atomic modification X of M such that A reads the value stored by +X and X precedes B in the modification order of M, or

  4. +
+
+

+According to p3 (emphasize mine) +

+
+Effects: Initializes the object with the value desired. Initialization is not an atomic operation +(). +
+

+So, how does p3 apply to this example such that the load operation precedes +the store operation in the single total order S? +

+
+ + +

+

+
+ +