From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by sourceware.org (Postfix) with ESMTPS id 3E85D3858C3A; Fri, 10 Dec 2021 00:38:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3E85D3858C3A Received: by mail-oi1-x236.google.com with SMTP id n66so11106771oia.9; Thu, 09 Dec 2021 16:38:05 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=nqQT2KXdIePLgN0569Cc1cP4T1KZd82pqPKmyXikVfg=; b=XDU52O6GKJ/KP5l5ttoczXcmQh/M5RYZAvfm85GTgxECI0iv4KNg11vRWnUus8iApn S0lk6kHWIXhcf7eOKCYO2WlNPKflCOR9tBysFywJozM978upVmI2KDa8JRkAuJdFYtTp FnMeWNJQSX95RpFK7xZMqLToeN7I6/PMzevpKLtbm6KjG3J0/y5e3qCUMKJ+iXVqo8AE S8zoqoi2fgoZIyN2wJq3RTMj2AayweA8stqcWrek+XzUGnIwZ4NSz6ndAilt57IL1yNx wpC7snmZu+vSvl86rbhZ3S6enIL2TfDg07AL7JABDjhfJksPT3YIqCpSH/hJYae9Ah9p yrSg== X-Gm-Message-State: AOAM532Cc6jmX6S3oWNHead7eiPClSTyTgp6iGIKyuLAdp/MrKPeaA6o Fzmc6A1/1zfMVgqXuyqxEh/2iyIIBy8= X-Google-Smtp-Source: ABdhPJxWTkggWeXQuRUTczPfK7DIE0DnGHdjOln2fQzawyo1dlVPavAhXqIjzz2D63uXN19UI3wSjA== X-Received: by 2002:aca:1115:: with SMTP id 21mr9531002oir.137.1639096684590; Thu, 09 Dec 2021 16:38:04 -0800 (PST) Received: from [192.168.0.41] (184-96-227-137.hlrn.qwest.net. [184.96.227.137]) by smtp.gmail.com with ESMTPSA id y12sm402644oiv.49.2021.12.09.16.38.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Dec 2021 16:38:04 -0800 (PST) Subject: Re: [committed] libstdc++: Disable over-zealous warnings about std::string copies [PR103332] To: Jonathan Wakely , libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org References: <20211209232453.1568609-1-jwakely@redhat.com> From: Martin Sebor Message-ID: Date: Thu, 9 Dec 2021 17:38:03 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20211209232453.1568609-1-jwakely@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 10 Dec 2021 00:38:07 -0000 On 12/9/21 4:24 PM, Jonathan Wakely via Gcc-patches wrote: > These warnings are triggered by perfectly valid code using std::string. > They're particularly bad when --enable-fully-dynamic-string is used, > because even std::string().begin() will give a warning. > > Use pragmas to stop the troublesome warnings for copies done by > std::char_traits. I'm still experimenting with some of the approaches we discussed last week, but based on my findings so far this was going to be my suggestion at lest for now, until or unless the problem turns out to affect more code than just std::string. That said, I noticed a typo in the patch: > > libstdc++-v3/ChangeLog: > > PR libstdc++/103332 > PR libstdc++/102958 > PR libstdc++/103483 > * include/bits/char_traits.h: Suppress stringop and array-bounds > warnings. > --- > libstdc++-v3/include/bits/char_traits.h | 7 +++++++ > 1 file changed, 7 insertions(+) > > diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h > index da3e0ffffaa..3f7befcf8b2 100644 > --- a/libstdc++-v3/include/bits/char_traits.h > +++ b/libstdc++-v3/include/bits/char_traits.h > @@ -54,6 +54,11 @@ namespace __gnu_cxx _GLIBCXX_VISIBILITY(default) > { > _GLIBCXX_BEGIN_NAMESPACE_VERSION > > +#pragma GCC diagnostic push > +#pragma GCC diagnostic ignored "-Wstringop-overflow" > +#pragma GCC diagnostic ignored "-Wstringop-overread" > +#pragma GCC diagnostic ignored "-Warray-bounds" (Just for reference, as I mentioned in my private mail, at -O1 the same code also triggers -Wfree-nonheap-object.) > + > /** > * @brief Mapping from character type to associated types. > * > @@ -990,6 +995,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > } // namespace __detail > #endif // C++20 > > +#pragma GCC diagnostic push This should be pop. Martin > + > _GLIBCXX_END_NAMESPACE_VERSION > } // namespace > >