Skip to content

Commit aaf570c

Browse files
committed
Set status=SG1 and priority for 4174
1 parent eecdfa3 commit aaf570c

File tree

1 file changed

+61
-2
lines changed

1 file changed

+61
-2
lines changed

xml/issue4174.xml

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version='1.0' encoding='utf-8' standalone='no'?>
22
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
33

4-
<issue num="4174" status="New">
4+
<issue num="4174" status="SG1">
55
<title>How does [atomics.order] p3 apply when then modification is an initialization?</title>
66
<section><sref ref="[atomics.order]"/></section>
77
<submitter>jim x</submitter>
88
<date>13 Nov 2024</date>
9-
<priority>99</priority>
9+
<priority>3</priority>
1010

1111
<discussion>
1212
<p>
@@ -46,6 +46,65 @@ According to <sref ref="[atomics.types.operations]"/> p3 (emphasize mine)
4646
So, how does <sref ref="[atomics.order]"/> p3 apply to this example such that the load operation precedes
4747
the store operation in the single total order <i>S</i>?
4848
</p>
49+
50+
<note>2025-02-07; Reflector poll</note>
51+
<p>
52+
Set priority to 3 after reflector poll. Send to SG1.
53+
</p>
54+
<p>
55+
LWG found the issue unclear and felt it was missing context that would
56+
help understand it properly.
57+
</p>
58+
<p>
59+
In
60+
<a href="https://github.com/cplusplus/CWG/issues/641">cplusplus/CWG/issues/641</a>
61+
the following example was given:
62+
<blockquote>
63+
<pre>
64+
std::atomic&lt;bool&gt; a = false;
65+
std::atomic&lt;bool&gt; b = false;
66+
int v = 0;
67+
// thread 1:
68+
a.store(true, seq_cst);
69+
if(b.load(seq_cst)== false){
70+
v = 1; // #1
71+
}
72+
//thread 2:
73+
b.store(true, seq_cst);
74+
if(a.load(seq_cst)== false){
75+
v = 2; // #2
76+
}
77+
</pre>
78+
To prove whether #1 and #2 can have data race, we should prove whether
79+
it's possible that `a` and `b` simultaneously read `false`.
80+
This proof equals whether there can be a valid single total order in this case.
81+
To determine the order of `b.load` and `b.store` when `b.load` reads
82+
the initialization value `false`, <sref ref="[atomics.order]"/> p3.3
83+
should apply here.
84+
However, the initialization is not an atomic modification
85+
such that `X` cannot be that value.
86+
</blockquote>
87+
</p>
88+
89+
<p>
90+
A possible fix is to amend <sref ref="[atomics.order]"/>/3.3 to say something
91+
like this:
92+
<blockquote>
93+
(3.3) A and B are not the same atomic read-modify-write operation, and
94+
<ins>either</ins>
95+
<ol style="list-style-type: none">
96+
<li><ins>(3.3.1)</ins>
97+
there exists an atomic modification X of M such that A reads
98+
the value stored by X and X precedes B in the modification order of M<ins>,
99+
or</ins>
100+
</li>
101+
<li><ins>(3.3.2)
102+
A reads the initial value of X and B modifies M</ins>, or
103+
</li>
104+
</ol>
105+
</blockquote>
106+
</p>
107+
49108
</discussion>
50109

51110
<resolution>

0 commit comments

Comments
 (0)