Skip to content

Commit 4078763

Browse files
authored
[libc++] Fix copy/pasta error in atomic tests for atomic_compare_exchange_{weak,strong} (#87135)
Spotted this minor mistake in the tests as I was looking into testing more thoroughly `atomic_ref`. The two argument overloads are tested just above. The names of the lambda clearly indicates that the intent was to test the one argument overload.
1 parent 718638d commit 4078763

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_strong.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,12 @@ void test_impl() {
150150
test_seq_cst<T, MaybeVolatile>(store, load);
151151

152152
auto store_one_arg = [](MaybeVolatile<std::atomic<T>>& x, T old_val, T new_val) {
153-
auto r = x.compare_exchange_strong(old_val, new_val, std::memory_order::seq_cst, std::memory_order_relaxed);
153+
auto r = x.compare_exchange_strong(old_val, new_val, std::memory_order::seq_cst);
154154
assert(r);
155155
};
156156
auto load_one_arg = [](MaybeVolatile<std::atomic<T>>& x) {
157157
auto val = x.load(std::memory_order::relaxed);
158-
while (!x.compare_exchange_strong(val, val, std::memory_order::seq_cst, std::memory_order_relaxed)) {
158+
while (!x.compare_exchange_strong(val, val, std::memory_order::seq_cst)) {
159159
}
160160
return val;
161161
};

libcxx/test/std/atomics/atomics.types.generic/atomics.types.float/compare_exchange_weak.pass.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ void test_impl() {
165165

166166
auto store_one_arg = [](MaybeVolatile<std::atomic<T>>& x, T old_val, T new_val) {
167167
// could fail spuriously, so put it in a loop
168-
while (!x.compare_exchange_weak(old_val, new_val, std::memory_order::seq_cst, std::memory_order_relaxed)) {
168+
while (!x.compare_exchange_weak(old_val, new_val, std::memory_order::seq_cst)) {
169169
}
170170
};
171171
auto load_one_arg = [](MaybeVolatile<std::atomic<T>>& x) {
172172
auto val = x.load(std::memory_order::relaxed);
173-
while (!x.compare_exchange_weak(val, val, std::memory_order::seq_cst, std::memory_order_relaxed)) {
173+
while (!x.compare_exchange_weak(val, val, std::memory_order::seq_cst)) {
174174
}
175175
return val;
176176
};

0 commit comments

Comments
 (0)