public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-2702] libstdc++: Fix compare_exchange_padding.cc test for std::atomic_ref
@ 2022-09-16 20:19 Jonathan Wakely
0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2022-09-16 20:19 UTC (permalink / raw)
To: gcc-cvs, libstdc++-cvs
https://gcc.gnu.org/g:47deb1ef874c078ac51bc1970a3324f5c8002815
commit r13-2702-g47deb1ef874c078ac51bc1970a3324f5c8002815
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Fri Sep 16 17:50:21 2022 +0100
libstdc++: Fix compare_exchange_padding.cc test for std::atomic_ref
This test was written assuming that std::atomic_ref clears its target's
padding on construction, but that could introduce data races. Change the
test to store a value after construction and check that its padding is
cleared by the store.
libstdc++-v3/ChangeLog:
* testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc:
Store value with non-zero padding bits after construction.
Diff:
---
.../29_atomics/atomic_ref/compare_exchange_padding.cc | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc b/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc
index 1b1a12dddda..e9f8a4bdf2a 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/compare_exchange_padding.cc
@@ -20,14 +20,15 @@ int
main ()
{
S s;
- fill_struct(s);
- s.c = 'a';
- s.s = 42;
-
S ss{ s };
+ fill_struct(ss);
+ ss.c = 'a';
+ ss.s = 42;
+
std::atomic_ref<S> as{ s };
+ as.store(ss);
auto ts = as.load();
- VERIFY( !compare_struct(ss, ts) ); // padding cleared on construction
+ VERIFY( !compare_struct(ss, ts) ); // padding cleared on store
as.exchange(ss);
auto es = as.load();
VERIFY( compare_struct(ts, es) ); // padding cleared on exchange
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-09-16 20:19 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-16 20:19 [gcc r13-2702] libstdc++: Fix compare_exchange_padding.cc test for std::atomic_ref Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).