Skip to content

Commit 25afda1

Browse files
committed
New issue from jim x: "Whether the spuriously failed comparison applies to compare_exchange_strong is unclear"
1 parent 1463af3 commit 25afda1

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

xml/issue4244.xml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version='1.0' encoding='utf-8' standalone='no'?>
2+
<!DOCTYPE issue SYSTEM "lwg-issue.dtd">
3+
4+
<issue num="4244" status="New">
5+
<title>Whether the spuriously failed comparison applies to `compare_exchange_strong` is unclear</title>
6+
<section>
7+
<sref ref="[atomics.ref.ops]"/><sref ref="[atomics.types.operations]"/>
8+
</section>
9+
<submitter>jim x</submitter>
10+
<date>17 Apr 2025</date>
11+
<priority>99</priority>
12+
13+
<discussion>
14+
<p>
15+
Both `compare_exchange_strong` and `compare_exchange_weak` share the same specified rule
16+
</p>
17+
<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;">
18+
<p>
19+
If and only if the comparison is `false` then, after the atomic operation, the value in
20+
`expected` is replaced by the value read from the value referenced by `*ptr` during the
21+
atomic comparison.
22+
</p>
23+
</blockquote>
24+
<p>
25+
However, there is a remark for the weak version
26+
</p>
27+
<blockquote style="border-left: 3px solid #ccc;padding-left: 15px;">
28+
<p>
29+
A weak compare-and-exchange operation may fail spuriously.
30+
</p>
31+
</blockquote>
32+
<p>
33+
That is, even when the contents of memory referred to by `expected` and `ptr` are equal,
34+
it may return `false` and store back to expected the same memory contents that were
35+
originally there.
36+
<p/>
37+
However, we don't explicitly say whether the strong version can have the spuriously failed
38+
comparison. The status quo is that we can only infer the point from the name, namely, the
39+
strong version should have a stronger guarantee than the weak version.
40+
<p/>
41+
<b>Suggested resolution:</b>
42+
<p/>
43+
Explicitly specify whether `compare_exchange_strong` can have the spurious failed comparison.
44+
</p>
45+
</discussion>
46+
47+
<resolution>
48+
</resolution>
49+
50+
</issue>

0 commit comments

Comments
 (0)