[committed] libstdc++: Only support atomic_ref::wait tests which are always lockfree

Message ID 20210609205236.1323202-1-rodgert@appliantology.com
State New
Headers show
Series
  • [committed] libstdc++: Only support atomic_ref::wait tests which are always lockfree
Related show

Commit Message

Thomas Rodgers June 9, 2021, 8:52 p.m.
Fixes a regression on arm32 targets.

libstdc++/ChangeLog:
	* testsuite/29_atomics/atomic_ref/wait_notify.cc: Guard
	test logic with constexpr check for is_always_lock_free.

As discussed on IRC.

Tested x86_64-pc-linux-gnu, committed to master, backported to
releases/gcc-11.
---
 .../29_atomics/atomic_ref/wait_notify.cc      | 23 +++++++++++--------
 1 file changed, 13 insertions(+), 10 deletions(-)

-- 
2.26.2

Patch

diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
index 2500dddf884..c21c3a11ab5 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
@@ -30,17 +30,20 @@  template<typename S>
   void
   test (S va, S vb)
   {
-    S aa{ va };
-    S bb{ vb };
-    std::atomic_ref<S> a{ aa };
-    a.wait(bb);
-    std::thread t([&]
+    if constexpr (std::atomic_ref<S>::is_always_lock_free)
       {
-        a.store(bb);
-        a.notify_one();
-      });
-    a.wait(aa);
-    t.join();
+        S aa{ va };
+        S bb{ vb };
+        std::atomic_ref<S> a{ aa };
+        a.wait(bb);
+        std::thread t([&]
+          {
+            a.store(bb);
+            a.notify_one();
+          });
+        a.wait(aa);
+        t.join();
+      }
   }
 
 int