From patchwork Tue Jun 8 00:28:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Rodgers X-Patchwork-Id: 1489022 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (4096-bit key; secure) header.d=kolabnow.com header.i=@kolabnow.com header.a=rsa-sha256 header.s=dkim20160331 header.b=AK+9m6/3; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FzWMW0kPsz9sRN for ; Tue, 8 Jun 2021 10:29:25 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 979AC393BC24 for ; Tue, 8 Jun 2021 00:29:22 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx.kolabnow.com (mx.kolabnow.com [95.128.36.41]) by sourceware.org (Postfix) with ESMTPS id 3DAD0385782C; Tue, 8 Jun 2021 00:29:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3DAD0385782C Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=appliantology.com Authentication-Results: sourceware.org; spf=none smtp.mailfrom=appliantology.com Received: from localhost (unknown [127.0.0.1]) by ext-mx-out003.mykolab.com (Postfix) with ESMTP id 87491418E4; Tue, 8 Jun 2021 02:28:59 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from:received :received:received; s=dkim20160331; t=1623112133; x=1624926534; bh=H8IXjYlwuEhmGUvR74lczedM/0cDn47b5O+mRZ7CwX4=; b=AK+9m6/3nLhp E6X99X9ilnsXpzw7v1DvO+4bouyyfsMKGOdaYSmsxWpeDxw123A2G/KeEC6bJ2Tt V85U+viwsp+XheE2tuI2cF78fNfdhmwIAvXBpnaVlTMgm9ALuWepToBXh2jnOIkf LlOWQtK9FCX+2oUiBT+JxpV4yGyDLvVooxtir4bR6f/kcav+vcq6eTTSQi5YXbQH hqG5ho0VkNDDq1tFhv1O262hSEpK48z8LvRB2zhX0pzgiCvFShB6WXrfpZXV9/uF vBiIr7pK1II6Fh1fZHohw8qkWSQSoCJcQ6D0rKyg3buVU/U9OVd0XZ8vxwnPK/Mf 41lf2Xd9Jm90vrEvJCAFB+6ttvEwukgMIxzwRPJ3XgCR6UZYuvbTAkGqNi/mVoqh yFHJyRy/GHzsxSVw8nRpEN2WLspd5P/2On4l2cIwI8yVcVQM3FSXZe3fOlKVCBeP txIfX2XkAzht74pFo+4x5DqBrCBW/ORLZflY5eaoRpx+ZmFsX54yQmsE9CK9fIpY YxFuoXu5Pmagsi7U15xeDeBx5Rxw0voGHZqw5Yk7Qry95PzvtHUbgBTvvUr60hjH R3V1bHt/E3dykrqG39DQOTVcDXUU5tpb0hMBS29J4ZlsCANMXqE1xm/P1w4i9tJF gMHWPFmAzGXs8Mkv25Zfyg4vczwlrFE= X-Virus-Scanned: amavisd-new at mykolab.com X-Spam-Score: -1.899 X-Spam-Level: X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.2 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out003.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E2R1BM8cPGoW; Tue, 8 Jun 2021 02:28:53 +0200 (CEST) Received: from int-mx001.mykolab.com (unknown [10.9.13.1]) by ext-mx-out003.mykolab.com (Postfix) with ESMTPS id 56C6440B5D; Tue, 8 Jun 2021 02:28:52 +0200 (CEST) Received: from ext-subm002.mykolab.com (unknown [10.9.6.2]) by int-mx001.mykolab.com (Postfix) with ESMTPS id BED955A1; Tue, 8 Jun 2021 02:28:49 +0200 (CEST) From: Thomas Rodgers To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] libstdc++: Fix Wrong param type in :atomic_ref<_Tp*>::wait [PR100889] Date: Mon, 7 Jun 2021 17:28:43 -0700 Message-Id: <20210608002843.945023-1-rodgert@appliantology.com> In-Reply-To: <20210607220207.944400-1-rodgert@appliantology.com> References: <20210607220207.944400-1-rodgert@appliantology.com> MIME-Version: 1.0 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: trodgers@redhat.com Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This time without the repeatred [PRnnnn] in the subject line. Fixes libstdc++/100889 libstdc++-v3/ChangeLog: * 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. --- libstdc++-v3/include/bits/atomic_base.h | 2 +- .../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..2500dddf884 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 +template + void + test (S va, S vb) + { + S aa{ va }; + S bb{ vb }; + std::atomic_ref a{ aa }; + a.wait(bb); + std::thread t([&] + { + a.store(bb); + a.notify_one(); + }); + a.wait(aa); + t.join(); + } + int main () { + test(0, 42); + test(0, 42); + test(0u, 42u); + test(0.0f, 42.0f); + test(0.0, 42.0); + test(nullptr, reinterpret_cast(42)); + struct S{ int i; }; - S aa{ 0 }; - S bb{ 42 }; - - std::atomic_ref 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{ 0 }, S{ 42 }); return 0; }