public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/109299] [12/13 Regression] wrong warning on std::wstring with -O2 -std=c++20 -D_FORTIFY_SOURCE=2
Date: Tue, 28 Mar 2023 09:28:53 +0000	[thread overview]
Message-ID: <bug-109299-4-zA60wXCwJN@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109299-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109299

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This is not a library bug. The library code is:

      basic_string(basic_string&& __str) noexcept
      : _M_dataplus(_M_local_data(), std::move(__str._M_get_allocator()))
      {
        if (__str._M_is_local())
          {
            traits_type::copy(_M_local_buf, __str._M_local_buf,
                              __str.length() + 1);
          }
        else
          {
            _M_data(__str._M_data());
            _M_capacity(__str._M_allocated_capacity);
          }


The warning is coming from the call to traits_type::copy which only happens if
the string fits in the local buffer. Warning that it overflows the buffer is
not helpful when we don't take that branch BECAUSE IT WOULD OVERFLOW THE
BUFFER.

These warnings need to be removed from the compiler.

  parent reply	other threads:[~2023-03-28  9:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-27 15:01 [Bug libstdc++/109299] New: " benni.buch at gmail dot com
2023-03-27 15:38 ` [Bug tree-optimization/109299] " xry111 at gcc dot gnu.org
2023-03-27 20:57 ` redi at gcc dot gnu.org
2023-03-27 21:14 ` benni.buch at gmail dot com
2023-03-28  7:11 ` [Bug libstdc++/109299] [12/13 Regression] " rguenth at gcc dot gnu.org
2023-03-28  9:28 ` redi at gcc dot gnu.org [this message]
2023-03-28  9:37 ` redi at gcc dot gnu.org
2023-03-28  9:47 ` jakub at gcc dot gnu.org
2023-03-28 10:03 ` redi at gcc dot gnu.org
2023-03-28 10:05 ` redi at gcc dot gnu.org
2023-03-28 20:14 ` cvs-commit at gcc dot gnu.org
2023-03-28 23:33 ` [Bug libstdc++/109299] [12 " cvs-commit at gcc dot gnu.org
2023-03-28 23:34 ` redi at gcc dot gnu.org

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=bug-109299-4-zA60wXCwJN@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).