From patchwork Fri Mar 31 14:50:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 77802 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp621158vqo; Fri, 31 Mar 2023 07:53:13 -0700 (PDT) X-Google-Smtp-Source: AKy350Z4t42QHeFK7JKmpf0QviXZzL5c5ZdBYUY2rgzy3DMSkaNbINy9wCIDXh97bI5N+ggYX0Ea X-Received: by 2002:a05:6402:34c7:b0:500:2a9d:1870 with SMTP id w7-20020a05640234c700b005002a9d1870mr10143390edc.13.1680274393637; Fri, 31 Mar 2023 07:53:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680274393; cv=none; d=google.com; s=arc-20160816; b=kz++FZVZXtUt/pWDYagHJPJLkYHmF61t0Y19w42GnhBRSbcsB+H7+tLkG1uv0n0dOk jKXpfk922WqCXxtvhsOQcEdEEHe1WuPUNgpZTy4AX+5ptgwuyuTMHuFiB9O+karC/2hh lYpKD0EtZZGfXw3rfvvyaDbURYTJK9Rzg67V0j1TISS9NlBuG2c7u71TlwJ3uCL2iADv TmLa0qauqY4kq8xigcMGzo9JJxztsIkeWZbFewVbZ30nnD6J8MWpd7q/+f1m6AwpNquc m5/vG696Rqfm/0DYi8AdBTdlTuNc25QrTuirFiQ4Z0WuSEsosoFjL62qMpXNtA4x744Z J9LQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=T82VTJsJYeF2TeCaCk7zgT5ukiIlUq7lZ5uGNKuBljY=; b=F1H8P8kDKS671EsGuPTzv8Y9ZVnMjlf0HpC6673ABze//X5sfPR74w+ynaS2a0U+uc GRl01WkZp4oLWutTxA+KRjDcdn2tH3J7fkjPV2x7lXpKN8v44eY0/AjYpC9WVqOxUdJ+ MAHJWpzIioGwukc/ZXzArkbv/UdFlwoSaQUk9uyrkeewEip19OeH5LfJtIEY1rB4zMh6 ni4KZUbs/3zR4AQ7uRrmKwMpxurSrOwRDEbUmHzujJqPmWUFdEjqxvpFpN+zQwwR2VE3 QlTPyLHy35xaGf0KQjAT9O2ZvRisgYyV3y41O1ckJWTB0+7rpKciqpgfJwi2h3+faw6n 5BQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="jQebi/a7"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id x26-20020aa7cd9a000000b0050270e743d4si2266136edv.590.2023.03.31.07.53.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Mar 2023 07:53:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="jQebi/a7"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6FB74384D190 for ; Fri, 31 Mar 2023 14:52:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6FB74384D190 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680274330; bh=T82VTJsJYeF2TeCaCk7zgT5ukiIlUq7lZ5uGNKuBljY=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=jQebi/a77SswMiRcflJrhxw2ZUvf4XhXleBMeoHVXTRkroepZhGlzAN5QdKykgCIJ qphgtD8nJRw0I3VhZpZW1M7Z+H6s7IifaZUjfP9JpUGtfhffwrXEyNsk1KEM6BHAI6 jkjyy0iC1xzBuYJytW3vn0Gpx4UyDbps4+pm9SuU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org 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 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) 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 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 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: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761895402556066165?= X-GMAIL-MSGID: =?utf-8?q?1761895402556066165?= 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 } +}