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.129.124]) by sourceware.org (Postfix) with ESMTPS id 1F10D38582BE for ; Tue, 25 Oct 2022 16:35:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1F10D38582BE 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=1666715743; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=l4xAp+Q+9hoGohjSoXo35w3M5ko+cIlJn6kSOIMgtZg=; b=SkWq7lQCMWuxliM0HOq2fnK1Htg+N0qakwmBDENb4qS6GZFf+jUGgCTAg0Je6DLFhvQxBh lRdq439buIcIz+qZaP3NZodWRX27cyyLs4EnZ+JOKXX0DrWFTx9jeatsLb2P8iAdSsSslx WtDzr8t+9ZNx6RV1lhzgUSFi2ZiZ+Ro= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-605-AwUBHmIUMKm7fnGPMeHM2Q-1; Tue, 25 Oct 2022 12:35:41 -0400 X-MC-Unique: AwUBHmIUMKm7fnGPMeHM2Q-1 Received: by mail-qt1-f198.google.com with SMTP id 17-20020ac85711000000b0039ccd4c9a37so9466312qtw.20 for ; Tue, 25 Oct 2022 09:35:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=l4xAp+Q+9hoGohjSoXo35w3M5ko+cIlJn6kSOIMgtZg=; b=GyjABc27X/wX5td6aUkOLmqVmrvOJRJoipL2mCjN0FZByUp0ECMcIyyP0UonGpELEi VANA2pZoeloVHfMBa5MiuFy4xOi7nZiQMwKsKJoGWT1diYLFKdYc9VeiLY9OsLnmIzE0 MWTXHVH6uIWMXRDITXGasxbobgmn51Ho2znMB8yNDdXI1tw7sNMv51F2/kC7yK+hgdfu zJqrtthqAx9FmoQzDZslc3Du+K+bnsAHkD421wp+veX/i0z7ntkEW+4es/xtj5Pru0uc mQhQe+gAhZPmkkAU439WxDNnZG8ob75MVu5CJiXmvdeKUapby+hk1ej9wG5FvHpdwCii NxNw== X-Gm-Message-State: ACrzQf38/fOuLRsfA52H1Bfp8e7M09gI8oIcornkkZdudTKT24Cz2nPY KR27DFpXJ8m0phxaKs3cxgv9lVqkCG0FbADuL3niTLOF0T+m3A4dgncrl2BDHWjBGFQr9mUHVWS zoE6yYcT+v+uDb44H4w== X-Received: by 2002:a05:622a:d6:b0:39c:dea1:b706 with SMTP id p22-20020a05622a00d600b0039cdea1b706mr32713596qtw.263.1666715741302; Tue, 25 Oct 2022 09:35:41 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4hJ1TbY9hFp170kYdNH7nWqCQNMiD5OoDXchf5nirpgOY4gubL+oaQz61+2Qwu4cNPD3X/xw== X-Received: by 2002:a05:622a:d6:b0:39c:dea1:b706 with SMTP id p22-20020a05622a00d600b0039cdea1b706mr32713571qtw.263.1666715741044; Tue, 25 Oct 2022 09:35:41 -0700 (PDT) Received: from redhat.com (2603-7000-9500-2e39-0000-0000-0000-1db4.res6.spectrum.com. [2603:7000:9500:2e39::1db4]) by smtp.gmail.com with ESMTPSA id he19-20020a05622a601300b0039cc7ebf46bsm1799564qtb.93.2022.10.25.09.35.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 09:35:40 -0700 (PDT) Date: Tue, 25 Oct 2022 12:35:38 -0400 From: Marek Polacek To: Jason Merrill Cc: Jonathan Wakely , GCC Patches Subject: Re: [PATCH] c++: Implement -Wdangling-reference [PR106393] Message-ID: References: <20221021232824.1093138-1-polacek@redhat.com> <94b6bf22-bf2c-f6c0-3ac6-ca2c89bfde2e@redhat.com> MIME-Version: 1.0 In-Reply-To: <94b6bf22-bf2c-f6c0-3ac6-ca2c89bfde2e@redhat.com> User-Agent: Mutt/2.2.7 (2022-08-07) X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Oct 25, 2022 at 11:39:31AM -0400, Jason Merrill wrote: > On 10/25/22 09:14, Marek Polacek wrote: > > On Tue, Oct 25, 2022 at 12:34:50PM +0100, Jonathan Wakely wrote: > > > On Mon, 24 Oct 2022 at 18:30, Jason Merrill wrote: > > > > > > > > On 10/21/22 19:28, Marek Polacek wrote: > > > > > When testing a previous version of the patch, there were many FAILs in > > > > > libstdc++'s 22_locale/; all of them because the warning triggered on > > > > > > > > > > const test_type& obj = std::use_facet(std::locale()); > > > > > > > > > > but this code looks valid -- std::use_facet doesn't return a reference > > > > > to its parameter. Therefore I added code to suppress the warning when > > > > > the call is std::use_facet. Now 22_locale/* pass even with the warning > > > > > on. We could exclude more std:: functions like this if desirable. > > > > > > > > Instead of adding special cases in the compiler, let's disable the > > > > warning around the definition of use_facet (and adjust the compiler as > > > > needed so that avoids the warning). > > > > > > I assume you mean using #pragma here. If we disable it around the > > > definition of use_facet, will that disable it for callers of > > > use_facet, or only within the definition of use_facet itself? > > > > Right, a #pragma will not help, it would only disable the warning > > within the definition of use_facet itself. > > That's why I mentioned adjusting the compiler, i.e. check warning_enabled_at > (DECL_SOURCE_LOCATION (fn) Ah, like with -Wdeprecated-copy. I think I fixed this: --- a/libstdc++-v3/include/bits/locale_classes.tcc +++ b/libstdc++-v3/include/bits/locale_classes.tcc @@ -127,6 +127,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * @return Reference to facet of type Facet. * @throw std::bad_cast if @p __loc doesn't contain a facet of type _Facet. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdangling-reference" template const _Facet& use_facet(const locale& __loc) @@ -141,6 +143,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return static_cast(*__facets[__i]); #endif } +#pragma GCC diagnostic pop // Generic version does nothing. and then just check warning_enabled_at. Nice! Marek