https://gcc.gnu.org/g:f3ba5ad088cebe117f857329a35b95d18d97a808

commit r16-7556-gf3ba5ad088cebe117f857329a35b95d18d97a808
Author: Tomasz Kamiński <[email protected]>
Date:   Tue Feb 17 13:35:39 2026 +0100

    libstdc++: Correct requirements for atomic/cons/zero_padding.cc tests again 
[PR124124]
    
    The requirements introduced in previous patch r16-7548-g060d7c2a9c1fe1,
    were not sufficient for types of size bigger than 64B (Ctor or long double),
    as dg-add-options of libatomic, links libatomic only if it is required to
    handle atomics of 64B types or pointers.
    
    This patch addresses above, by reducing the size of Ctor struct to fit in
    64 bytes, and moving long double test to separate file, that requires and
    links with libatomic.
    
            PR libstdc++/124124
    
    libstdc++-v3/ChangeLog:
    
            * testsuite/29_atomics/atomic/cons/zero_padding.cc: Updated
            Ctor class and move test_floating to...
            * testsuite/29_atomics/atomic_float/zero_padding.cc: Extracted
            test_floating.
    
    Reviewed-by: Jonathan Wakely <[email protected]>
    Signed-off-by: Tomasz Kamiński <[email protected]>

Diff:
---
 .../29_atomics/atomic/cons/zero_padding.cc         | 41 +-------------------
 .../29_atomics/atomic_float/zero_padding.cc        | 45 ++++++++++++++++++++++
 2 files changed, 46 insertions(+), 40 deletions(-)

diff --git a/libstdc++-v3/testsuite/29_atomics/atomic/cons/zero_padding.cc 
b/libstdc++-v3/testsuite/29_atomics/atomic/cons/zero_padding.cc
index 3c8a4a8f428a..f85ac4859ec5 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic/cons/zero_padding.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic/cons/zero_padding.cc
@@ -26,12 +26,11 @@ struct Ctor
   Ctor() = default;
 
   constexpr Ctor(char pc, char pi)
-    : c(pc), i(pi), d(pc)
+    : c(pc), i(pi)
   {}
 
   char c;
   int i;
-  char d;
 };
 
 Ctor zctor{1, 2}; // zeroed-padding
@@ -67,48 +66,10 @@ void test_struct(std::atomic<T>& g, const T& zp)
   constexpr std::atomic<T> cl(T{1, 2});
 }
 
-#if __cplusplus >= 202002L
-long double zld(10.5);
-constexpr std::atomic<long double> cld(10.5);
-std::atomic<long double> gld(10.5);
-
-template<typename T>
-void test_floating(std::atomic<T>& g, const T& zp)
-{
-  T const d = T(7.5);
-  T t;
-
-  std::memcpy(&t, &zp, sizeof(T));
-  VERIFY( g.compare_exchange_strong(t, d) );
-
-  static std::atomic<T> st(T(10.5));
-  std::memcpy(&t, &zp, sizeof(T));
-  VERIFY( st.compare_exchange_strong(t, d) );
-
-  thread_local std::atomic<T> tl(T(10.5));
-  std::memcpy(&t, &zp, sizeof(T));
-  VERIFY( tl.compare_exchange_strong(t, d) );
-
-  std::atomic<T> l(T(10.5));
-  std::memcpy(&t, &zp, sizeof(T));
-  VERIFY( l.compare_exchange_strong(t, d) );
-
-  std::atomic<T>* h = new std::atomic<T>(T(10.5));
-  std::memcpy(&t, &zp, sizeof(T));
-  VERIFY( h->compare_exchange_strong(t, d) );
-  delete h;
-
-  constexpr std::atomic<T> cl(T(10.5));
-}
-#endif
-
 int main()
 {
   test_struct(gtail, ztail);
   test_struct(gmid, zmid);
   test_struct(gbit, zbit);
   test_struct(gctor, zctor);
-#if __cplusplus >= 202002L
-  test_floating(gld, zld);
-#endif
 }
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_float/zero_padding.cc 
b/libstdc++-v3/testsuite/29_atomics/atomic_float/zero_padding.cc
new file mode 100644
index 000000000000..26e9d11b574a
--- /dev/null
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_float/zero_padding.cc
@@ -0,0 +1,45 @@
+// { dg-do run { target c++20 } }
+// { dg-require-effective-target libatomic_available }
+// { dg-additional-options "[atomic_link_flags [get_multilibs]] -latomic" }
+
+#include <atomic>
+#include <cstring>
+#include <testsuite_hooks.h>
+
+long double zld(10.5);
+constexpr std::atomic<long double> cld(10.5);
+std::atomic<long double> gld(10.5);
+
+template<typename T>
+void test_floating(std::atomic<T>& g, const T& zp)
+{
+  T const d = T(7.5);
+  T t;
+
+  std::memcpy(&t, &zp, sizeof(T));
+  VERIFY( g.compare_exchange_strong(t, d) );
+
+  static std::atomic<T> st(T(10.5));
+  std::memcpy(&t, &zp, sizeof(T));
+  VERIFY( st.compare_exchange_strong(t, d) );
+
+  thread_local std::atomic<T> tl(T(10.5));
+  std::memcpy(&t, &zp, sizeof(T));
+  VERIFY( tl.compare_exchange_strong(t, d) );
+
+  std::atomic<T> l(T(10.5));
+  std::memcpy(&t, &zp, sizeof(T));
+  VERIFY( l.compare_exchange_strong(t, d) );
+
+  std::atomic<T>* h = new std::atomic<T>(T(10.5));
+  std::memcpy(&t, &zp, sizeof(T));
+  VERIFY( h->compare_exchange_strong(t, d) );
+  delete h;
+
+  constexpr std::atomic<T> cl(T(10.5));
+}
+
+int main()
+{
+  test_floating(gld, zld);
+}

Reply via email to