From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 64468387091D for ; Fri, 31 Mar 2023 14:50:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 64468387091D Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680274222; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T82VTJsJYeF2TeCaCk7zgT5ukiIlUq7lZ5uGNKuBljY=; b=CoOtBXgcB5I/Wdn2toLIqMtgqaxu/juqhVsIhSoiIiSQvM8MH0Ve25BDHBHS1riFhAbFSo rbnBTxdyWKpMT8VxxUCVYintVn/Lw19xe4LjqsDVyZwAnWXQHRp3QFIz8eUNcTA6sJXAGC SvEW0hyC7wQNrKqTDWExEk1LHfP8w1s= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-358-NYN3ODQRPGeHZ2k07NwI3A-1; Fri, 31 Mar 2023 10:50:18 -0400 X-MC-Unique: NYN3ODQRPGeHZ2k07NwI3A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 039193823A0C; Fri, 31 Mar 2023 14:50:18 +0000 (UTC) Received: from localhost (unknown [10.33.36.223]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3D5D4042AC0; Fri, 31 Mar 2023 14:50:17 +0000 (UTC) From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Avoid -Wmaybe-uninitialized warning in std::stop_source [PR109339] Date: Fri, 31 Mar 2023 15:50:17 +0100 Message-Id: <20230331145017.30025-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP,URI_HEX autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Tested powerpc64le-linux. Pushed to trunk. -- >8 -- We pass a const-reference to *this before it's constructed, and GCC assumes that all const-references are accessed. Add the access attribute to say it's not accessed. libstdc++-v3/ChangeLog: PR libstdc++/109339 * include/std/stop_token (_Stop_state_ptr(const stop_source&)): Add attribute access with access-mode 'none'. * testsuite/30_threads/stop_token/stop_source/109339.cc: New test. --- libstdc++-v3/include/std/stop_token | 1 + .../30_threads/stop_token/stop_source/109339.cc | 10 ++++++++++ 2 files changed, 11 insertions(+) create mode 100644 libstdc++-v3/testsuite/30_threads/stop_token/stop_source/109339.cc diff --git a/libstdc++-v3/include/std/stop_token b/libstdc++-v3/include/std/stop_token index 76aef78a7ef..c90fc786b63 100644 --- a/libstdc++-v3/include/std/stop_token +++ b/libstdc++-v3/include/std/stop_token @@ -395,6 +395,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { _Stop_state_ref() = default; + [[__gnu__::__access__(__none__, 2)]] explicit _Stop_state_ref(const stop_source&) : _M_ptr(new _Stop_state_t()) diff --git a/libstdc++-v3/testsuite/30_threads/stop_token/stop_source/109339.cc b/libstdc++-v3/testsuite/30_threads/stop_token/stop_source/109339.cc new file mode 100644 index 00000000000..eea614eef80 --- /dev/null +++ b/libstdc++-v3/testsuite/30_threads/stop_token/stop_source/109339.cc @@ -0,0 +1,10 @@ +// { dg-options "-Wmaybe-uninitialized -Og -std=gnu++20" } +// { dg-do compile { target c++20 } } + +#include + +int main() +{ + std::stop_source ss; + // { dg-bogus "uninitialized" "PR 109339" { target *-*-* } 0 } +} -- 2.39.2