public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r10-8416] libstdc++: Fix atomic<long double> tests (PR 91153, PR 93224)
@ 2020-07-02 18:58 Jonathan Wakely
  0 siblings, 0 replies; only message in thread
From: Jonathan Wakely @ 2020-07-02 18:58 UTC (permalink / raw)
  To: gcc-cvs, libstdc++-cvs

https://gcc.gnu.org/g:14d4e7bc303a92f620eddcba9cef88da7e91514c

commit r10-8416-g14d4e7bc303a92f620eddcba9cef88da7e91514c
Author: Jonathan Wakely <jwakely.gcc@gmail.com>
Date:   Thu Jul 2 17:11:10 2020 +0000

    libstdc++: Fix atomic<long double> tests (PR 91153, PR 93224)
    
    These tests fail with AIX double double. Use different floating point
    values that behave less surprisingly.
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/91153
            PR target/93224
            * testsuite/29_atomics/atomic_float/1.cc: Use different values
            for tests.
            * testsuite/29_atomics/atomic_ref/float.cc: Likewise.
    
    (cherry picked from commit c6f431bba531bac3212b66069cf0f9718edf0132)

Diff:
---
 .../testsuite/29_atomics/atomic_float/1.cc         | 86 +++++++++++-----------
 .../testsuite/29_atomics/atomic_ref/float.cc       | 45 +++++------
 2 files changed, 67 insertions(+), 64 deletions(-)

diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_float/1.cc b/libstdc++-v3/testsuite/29_atomics/atomic_float/1.cc
index cf80c84bbb9..a38b040ee8f 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_float/1.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_float/1.cc
@@ -453,27 +453,28 @@ test03()
     ok = a1.compare_exchange_strong(expected, 3.2l, mo);
     VERIFY( !ok && a1.load() == 2.56l && expected == 2.56l );
 
-    f0 = a0.fetch_add(1.2l);
-    VERIFY( f0 == 12.8l );
-    VERIFY( a0 == 14.0l );
-    f1 = a1.fetch_add(2.4l, mo);
-    VERIFY( f1 == 2.56l );
-    VERIFY( a1 == 4.96l );
-
-    f0 = a0.fetch_sub(1.2l);
-    VERIFY( f0 == 14.0l );
-    VERIFY( a0 == 12.8l );
-    f1 = a1.fetch_sub(3.5l, mo);
-    VERIFY( f1 == 4.96l );
-    VERIFY( a1 == 1.46l );
-
-    f0 = a0 += 1.2l;
-    VERIFY( f0 == 14.0l );
-    VERIFY( a0 == 14.0l );
-
-    f0 = a0 -= 0.8l;
-    VERIFY( f0 == 13.2l );
-    VERIFY( a0 == 13.2l );
+    a1 = a0 = 0.5l;
+    f0 = a0.fetch_add(0.25l);
+    VERIFY( f0 == 0.5l );
+    VERIFY( a0 == 0.75l );
+    f1 = a1.fetch_add(0.25l, mo);
+    VERIFY( f1 == 0.5l );
+    VERIFY( a1 == 0.75l );
+
+    f0 = a0.fetch_sub(0.5l);
+    VERIFY( f0 == 0.75l );
+    VERIFY( a0 == 0.25l );
+    f1 = a1.fetch_sub(0.5l, mo);
+    VERIFY( f1 == 0.75l );
+    VERIFY( a1 == 0.25l );
+
+    f0 = a0 += 0.75l;
+    VERIFY( f0 == 1.0l );
+    VERIFY( a0 == 1.0l );
+
+    f0 = a0 -= 0.5l;
+    VERIFY( f0 == 0.5l );
+    VERIFY( a0 == 0.5l );
   }
 
   // Repeat for volatile std::atomic<long double>
@@ -540,27 +541,28 @@ test03()
     ok = a1.compare_exchange_strong(expected, 3.2l, mo);
     VERIFY( !ok && a1.load() == 2.56l && expected == 2.56l );
 
-    f0 = a0.fetch_add(1.2l);
-    VERIFY( f0 == 12.8l );
-    VERIFY( a0 == 14.0l );
-    f1 = a1.fetch_add(2.4l, mo);
-    VERIFY( f1 == 2.56l );
-    VERIFY( a1 == 4.96l );
-
-    f0 = a0.fetch_sub(1.2l);
-    VERIFY( f0 == 14.0l );
-    VERIFY( a0 == 12.8l );
-    f1 = a1.fetch_sub(3.5l, mo);
-    VERIFY( f1 == 4.96l );
-    VERIFY( a1 == 1.46l );
-
-    f0 = a0 += 1.2l;
-    VERIFY( f0 == 14.0l );
-    VERIFY( a0 == 14.0l );
-
-    f0 = a0 -= 0.8l;
-    VERIFY( f0 == 13.2l );
-    VERIFY( a0 == 13.2l );
+    a1 = a0 = 0.5l;
+    f0 = a0.fetch_add(0.25l);
+    VERIFY( f0 == 0.5l );
+    VERIFY( a0 == 0.75l );
+    f1 = a1.fetch_add(0.25l, mo);
+    VERIFY( f1 == 0.5l );
+    VERIFY( a1 == 0.75l );
+
+    f0 = a0.fetch_sub(0.5l);
+    VERIFY( f0 == 0.75l );
+    VERIFY( a0 == 0.25l );
+    f1 = a1.fetch_sub(0.5l, mo);
+    VERIFY( f1 == 0.75l );
+    VERIFY( a1 == 0.25l );
+
+    f0 = a0 += 0.75l;
+    VERIFY( f0 == 1.0l );
+    VERIFY( a0 == 1.0l );
+
+    f0 = a0 -= 0.5l;
+    VERIFY( f0 == 0.5l );
+    VERIFY( a0 == 0.5l );
   }
 }
 
diff --git a/libstdc++-v3/testsuite/29_atomics/atomic_ref/float.cc b/libstdc++-v3/testsuite/29_atomics/atomic_ref/float.cc
index 0aee9ceedcf..4726a14f9ca 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/float.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/float.cc
@@ -267,31 +267,32 @@ test03()
     ok = a.compare_exchange_strong(expected, 6.4l, mo);
     VERIFY( !ok && a.load() == 204.8l && expected == 204.8l );
 
-    v = a.fetch_add(3.2l);
-    VERIFY( v == 204.8l );
-    VERIFY( a == 208.0l );
-    v = a.fetch_add(-8.5l, mo);
-    VERIFY( v == 208.0l );
-    VERIFY( a == 199.5l );
-
-    v = a.fetch_sub(109.5l);
-    VERIFY( v == 199.5l );
-    VERIFY( a == 90.0l );
-    v = a.fetch_sub(2, mo);
-    VERIFY( v == 90.0l );
-    VERIFY( a == 88.0l );
-
-    v = a += 5.0l;
-    VERIFY( v == 93.0l );
-    VERIFY( a == 93.0l );
-
-    v = a -= 6.5l;
-    VERIFY( v == 86.5l );
-    VERIFY( a == 86.5l );
+    a = 0.5l;
+    v = a.fetch_add(0.5l);
+    VERIFY( v == 0.5l );
+    VERIFY( a == 1.0l );
+    v = a.fetch_add(-0.2l, mo);
+    VERIFY( v == 1.0l );
+    VERIFY( a == 0.8l );
+
+    v = a.fetch_sub(0.4l);
+    VERIFY( v == 0.8l );
+    VERIFY( a == 0.4l );
+    v = a.fetch_sub(-0.4l, mo);
+    VERIFY( v == 0.4l );
+    VERIFY( a == 0.8l );
+
+    v = a += .8l;
+    VERIFY( v == 1.6l );
+    VERIFY( a == 1.6l );
+
+    v = a -= 0.6l;
+    VERIFY( v == 1.0l );
+    VERIFY( a == 1.0l );
   }
 
   if constexpr (std::atomic_ref<long double>::is_always_lock_free)
-    VERIFY( value == 86.5l );
+    VERIFY( value == 1.0l );
 }
 
 void


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-07-02 18:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-02 18:58 [gcc r10-8416] libstdc++: Fix atomic<long double> tests (PR 91153, PR 93224) 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).