public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely.gcc@gmail.com>
To: Martin Sebor <msebor@gmail.com>
Cc: Jonathan Wakely <jwakely@redhat.com>,
	"libstdc++" <libstdc++@gcc.gnu.org>,
	 gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [committed] libstdc++: Disable over-zealous warnings about std::string copies [PR103332]
Date: Fri, 10 Dec 2021 09:51:11 +0000	[thread overview]
Message-ID: <CAH6eHdTX0ra0cQeC-495ubN8ugepwVN1ocDcaHb_4b34s9ENrw@mail.gmail.com> (raw)
In-Reply-To: <a5f8cdc0-68bc-b163-6a4b-53c598859b67@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2135 bytes --]

On Fri, 10 Dec 2021 at 00:39, Martin Sebor via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> 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.

Oops! thanks, fixed at r12-5888 by the attached patch. Tested
x86_64-linux, pushed to trunk.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 727 bytes --]

commit db184a3453b6fe810e2d9765ef8ed9028f96e968
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Fri Dec 10 09:06:37 2021

    libstdc++: Fix diagnostic pragma push that should be pop
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/char_traits.h: Change pragma push to pop.

diff --git a/libstdc++-v3/include/bits/char_traits.h b/libstdc++-v3/include/bits/char_traits.h
index 3f7befcf8b2..13239580622 100644
--- a/libstdc++-v3/include/bits/char_traits.h
+++ b/libstdc++-v3/include/bits/char_traits.h
@@ -995,7 +995,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   } // namespace __detail
 #endif // C++20
 
-#pragma GCC diagnostic push
+#pragma GCC diagnostic pop
 
 _GLIBCXX_END_NAMESPACE_VERSION
 } // namespace

      parent reply	other threads:[~2021-12-10  9:51 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-09 23:24 Jonathan Wakely
2021-12-10  0:38 ` Martin Sebor
2021-12-10  1:49   ` Martin Sebor
2021-12-10 10:12     ` Jonathan Wakely
2021-12-10 16:35       ` Martin Sebor
2021-12-10 16:41         ` Jakub Jelinek
2021-12-10 17:11           ` Martin Sebor
2021-12-10 17:17             ` Jakub Jelinek
2021-12-10 18:16               ` Jonathan Wakely
2021-12-10 18:10         ` Jonathan Wakely
2021-12-10  9:51   ` Jonathan Wakely [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH6eHdTX0ra0cQeC-495ubN8ugepwVN1ocDcaHb_4b34s9ENrw@mail.gmail.com \
    --to=jwakely.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jwakely@redhat.com \
    --cc=libstdc++@gcc.gnu.org \
    --cc=msebor@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).