public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Fix UB in atomic_ref/wait_notify.cc [PR101761]
@ 2021-09-16 22:14 Thomas Rodgers
  2021-09-16 23:39 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Thomas Rodgers @ 2021-09-16 22:14 UTC (permalink / raw)
  To: gcc-patches, libstdc++; +Cc: trodgers, Thomas Rodgers

From: Thomas Rodgers <rodgert@twrodgers.com>

Remove UB in atomic_ref/wait_notify test.

Signed-off-by: Thomas Rodgers <trodgers@redhat.com>

libstdc++-v3/ChangeLog:

	PR libstdc++/101761
	* testsuite/29_atomics/atomic_ref/wait_notify.cc (test): Use
	va and vb as arguments to wait/notify, remove unused bb local.

Tested x86_64-pc-linux-gnu, committed to master.
Ok to backport to releases/gcc-11?

---
 .../testsuite/29_atomics/atomic_ref/wait_notify.cc         | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

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 b75e27617f7..b41d1ac0bb7 100644
--- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
+++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
@@ -33,15 +33,14 @@ template<typename S>
     if constexpr (std::atomic_ref<S>::is_always_lock_free)
     {
       S aa{ va };
-      S bb{ vb };
       std::atomic_ref<S> a{ aa };
-      a.wait(bb);
+      a.wait(vb);
       std::thread t([&]
         {
-	  a.store(bb);
+	  a.store(vb);
 	  a.notify_one();
         });
-      a.wait(aa);
+      a.wait(va);
       t.join();
     }
   }
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libstdc++: Fix UB in atomic_ref/wait_notify.cc [PR101761]
  2021-09-16 22:14 [PATCH] libstdc++: Fix UB in atomic_ref/wait_notify.cc [PR101761] Thomas Rodgers
@ 2021-09-16 23:39 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2021-09-16 23:39 UTC (permalink / raw)
  To: Thomas Rodgers; +Cc: gcc-patches, libstdc++, Thomas Rodgers, Thomas Rodgers

On Thu, 16 Sep 2021, 23:24 Thomas Rodgers, <rodgert@appliantology.com>
wrote:

> From: Thomas Rodgers <rodgert@twrodgers.com>
>
> Remove UB in atomic_ref/wait_notify test.
>
> Signed-off-by: Thomas Rodgers <trodgers@redhat.com>
>
> libstdc++-v3/ChangeLog:
>
>         PR libstdc++/101761
>         * testsuite/29_atomics/atomic_ref/wait_notify.cc (test): Use
>         va and vb as arguments to wait/notify, remove unused bb local.
>
> Tested x86_64-pc-linux-gnu, committed to master.
> Ok to backport to releases/gcc-11?
>


Yes, ok for 11, thanks.



> ---
>  .../testsuite/29_atomics/atomic_ref/wait_notify.cc         | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
>
> 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 b75e27617f7..b41d1ac0bb7 100644
> --- a/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
> +++ b/libstdc++-v3/testsuite/29_atomics/atomic_ref/wait_notify.cc
> @@ -33,15 +33,14 @@ template<typename S>
>      if constexpr (std::atomic_ref<S>::is_always_lock_free)
>      {
>        S aa{ va };
> -      S bb{ vb };
>        std::atomic_ref<S> a{ aa };
> -      a.wait(bb);
> +      a.wait(vb);
>        std::thread t([&]
>          {
> -         a.store(bb);
> +         a.store(vb);
>           a.notify_one();
>          });
> -      a.wait(aa);
> +      a.wait(va);
>        t.join();
>      }
>    }
> --
> 2.31.1
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-16 23:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-16 22:14 [PATCH] libstdc++: Fix UB in atomic_ref/wait_notify.cc [PR101761] Thomas Rodgers
2021-09-16 23:39 ` 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).