public inbox for libstdc++-cvs@sourceware.org
help / color / mirror / Atom feed
From: Thomas Rodgers <rodgertq@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org, libstdc++-cvs@gcc.gnu.org
Subject: [gcc r11-8528] libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]
Date: Tue,  8 Jun 2021 23:02:32 +0000 (GMT)	[thread overview]
Message-ID: <20210608230232.29B11398547C@sourceware.org> (raw)

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

commit r11-8528-gd7462945387b33744f665d1aa33ba1cec79c03b0
Author: Thomas Rodgers <rodgert@appliantology.com>
Date:   Tue Jun 8 15:51:53 2021 -0700

    libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889]
    
    libstdc++-v3/ChangeLog:
    
            PR libstdc++/100889
            * include/bits/atomic_base.h (atomic_ref<_Tp*>::wait):
            Change parameter type from _Tp to _Tp*.
            * testsuite/29_atomics/atomic_ref/wait_notify.cc: Extend
            coverage of types tested.
    
    (cherry picked from commit 25e5ecdf82b49977e86bfaded236fb34af2705ed)

Diff:
---
 libstdc++-v3/include/bits/atomic_base.h            |  2 +-
 .../testsuite/29_atomics/atomic_ref/wait_notify.cc | 38 ++++++++++++++--------
 2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/libstdc++-v3/include/bits/atomic_base.h b/libstdc++-v3/include/bits/atomic_base.h
index 029b8ad65a9..20cf1343c58 100644
--- a/libstdc++-v3/include/bits/atomic_base.h
+++ b/libstdc++-v3/include/bits/atomic_base.h
@@ -1870,7 +1870,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
 #if __cpp_lib_atomic_wait
       _GLIBCXX_ALWAYS_INLINE void
-      wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept
+      wait(_Tp* __old, memory_order __m = memory_order_seq_cst) const noexcept
       { __atomic_impl::wait(_M_ptr, __old, __m); }
 
       // TODO add const volatile overload
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 2fd31304222..003b86c85d0 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
@@ -26,22 +26,34 @@
 
 #include <testsuite_hooks.h>
 
+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([&]
+      {
+	a.store(bb);
+	a.notify_one();
+      });
+    a.wait(aa);
+    t.join();
+  }
+
 int
 main ()
 {
+  test<int>(0, 42);
+  test<long>(0, 42);
+  test<unsigned>(0u, 42u);
+  test<float>(0.0f, 42.0f);
+  test<double>(0.0, 42.0);
+  test<void*>(nullptr, reinterpret_cast<void*>(42));
+
   struct S{ int i; };
-  S aa{ 0 };
-  S bb{ 42 };
-
-  std::atomic_ref<S> a{ aa };
-  VERIFY( a.load().i == aa.i );
-  a.wait(bb);
-  std::thread t([&]
-    {
-      a.store(bb);
-      a.notify_one();
-    });
-  a.wait(aa);
-  t.join();
+  test<S>(S{ 0 }, S{ 42 });
   return 0;
 }


                 reply	other threads:[~2021-06-08 23:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210608230232.29B11398547C@sourceware.org \
    --to=rodgertq@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    --cc=libstdc++-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).