public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Rodgers <rodgert@appliantology.com>
To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Cc: trodgers@redhat.com, Thomas Rodgers <rodgert@twrodgers.com>
Subject: [PATCH] libstdc++: Fix UB in atomic_ref/wait_notify.cc [PR101761]
Date: Thu, 16 Sep 2021 15:14:08 -0700	[thread overview]
Message-ID: <20210916221408.602576-1-rodgert@appliantology.com> (raw)

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


             reply	other threads:[~2021-09-16 22:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-16 22:14 Thomas Rodgers [this message]
2021-09-16 23:39 ` Jonathan Wakely

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=20210916221408.602576-1-rodgert@appliantology.com \
    --to=rodgert@appliantology.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=rodgert@twrodgers.com \
    --cc=trodgers@redhat.com \
    /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).