public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "Randy at miningrigrentals dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug middle-end/98465] Bogus -Wstringop-overread with -std=gnu++20 -O2 and std::string::insert
Date: Tue, 15 Feb 2022 10:50:52 +0000	[thread overview]
Message-ID: <bug-98465-4-kbdNvcIHUl@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-98465-4@http.gcc.gnu.org/bugzilla/>

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

--- Comment #38 from Randy <Randy at miningrigrentals dot com> ---
(In reply to Jonathan Wakely from comment #37)
> Please report a separate bug for vstring then.
> 
> (Your segfaults are probably because you're using c_str() on a temporary
> string, so accessing the pointer after the temporary goes out of scope.)

std::string is not thread safe, this is why vstring is used (from my memory). I
don't use c_str out of scope. I lost the documentation that exclaimed why to
use vstring instead of std string to me. At the time, vstring solved all of our
segaults in the internals of the string. Exactly why this is the case I don't
remember or even if its still an issue in newer gcc versions. The bug with the
warning in this thread exists in vstring as well.

I will look at filing a separate bug report then...

In static member function âstatic constexpr std::char_traits<char>::char_type*
std::char_traits<char>::copy(std::char_traits<char>::char_type*, const
char_type*, std::size_t)â,
    inlined from âstatic void __gnu_cxx::__vstring_utility<_CharT, _Traits,
_Alloc>::_S_copy(_CharT*, const _CharT*, __gnu_cxx::__vstring_utility<_CharT,
_Traits, _Alloc>::size_type) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>]â at
/usr/include/c++/11/ext/vstring_util.h:112:21,
    inlined from â__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>&
__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
_Base>::_M_replace(__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
_Base>::size_type, __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
_Base>::size_type, const _CharT*, __gnu_cxx::__versa_string<_CharT, _Traits,
_Alloc, _Base>::size_type) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>; _Base =
__gnu_cxx::__sso_string_base]â at /usr/include/c++/11/ext/vstring.tcc:160:20,
    inlined from â__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>&
__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
_Base>::replace(__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
_Base>::size_type, __gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
_Base>::size_type, const _CharT*, __gnu_cxx::__versa_string<_CharT, _Traits,
_Alloc, _Base>::size_type) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>; _Base =
__gnu_cxx::__sso_string_base]â at /usr/include/c++/11/ext/vstring.h:1313:19,
    inlined from â__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc, _Base>&
__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
_Base>::insert(__gnu_cxx::__versa_string<_CharT, _Traits, _Alloc,
_Base>::size_type, const _CharT*, __gnu_cxx::__versa_string<_CharT, _Traits,
_Alloc, _Base>::size_type) [with _CharT = char; _Traits =
std::char_traits<char>; _Alloc = std::allocator<char>; _Base =
__gnu_cxx::__sso_string_base]â at /usr/include/c++/11/ext/vstring.h:1085:29,
    inlined from âBouncedConnection::ReturnAction
BouncedConnection::Handle_Notify(rapidjson::Document&,
FullThreadCommandLogInstance&, String&)â at
BouncedConnectionCmdProcessing.cpp:2258:54:
/usr/include/c++/11/bits/char_traits.h:409:56: warning: âvoid*
__builtin_memcpy(void*, const void*, long unsigned int)â reading 2 bytes from a
region of size 1 [-Wstringop-overread]
  409 |         return static_cast<char_type*>(__builtin_memcpy(__s1, __s2,
__n));
      |                                       
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~

  parent reply	other threads:[~2022-02-15 10:50 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-28 18:36 [Bug middle-end/98465] New: Bogus warning stringop-overread wuth " romain.geissler at amadeus dot com
2020-12-28 20:54 ` [Bug middle-end/98465] " msebor at gcc dot gnu.org
2020-12-30 12:49 ` romain.geissler at amadeus dot com
2020-12-30 13:22 ` romain.geissler at amadeus dot com
2020-12-30 21:25 ` msebor at gcc dot gnu.org
2021-01-06 22:38 ` msebor at gcc dot gnu.org
2021-01-06 22:59 ` msebor at gcc dot gnu.org
2021-01-06 23:14 ` msebor at gcc dot gnu.org
2021-01-07 20:26 ` msebor at gcc dot gnu.org
2021-01-13 18:19 ` msebor at gcc dot gnu.org
2021-01-13 18:41 ` law at redhat dot com
2021-01-13 18:52 ` jakub at gcc dot gnu.org
2021-01-13 19:02 ` msebor at gcc dot gnu.org
2021-01-13 19:14 ` jakub at gcc dot gnu.org
2021-01-13 19:30 ` msebor at gcc dot gnu.org
2021-01-14  2:21 ` msebor at gcc dot gnu.org
2021-01-19 19:00 ` msebor at gcc dot gnu.org
2021-01-20 23:20 ` [Bug middle-end/98465] [11 Regression] Bogus -Wstringop-overread with " msebor at gcc dot gnu.org
2021-02-04 14:03 ` jakub at gcc dot gnu.org
2021-02-04 14:39 ` redi at gcc dot gnu.org
2021-02-04 15:25 ` jakub at gcc dot gnu.org
2021-02-04 15:53 ` redi at gcc dot gnu.org
2021-02-04 15:54 ` redi at gcc dot gnu.org
2021-02-04 16:02 ` msebor at gcc dot gnu.org
2021-02-04 16:58 ` jakub at gcc dot gnu.org
2021-02-04 17:12 ` jakub at gcc dot gnu.org
2021-02-04 20:57 ` msebor at gcc dot gnu.org
2021-02-04 21:09 ` jakub at gcc dot gnu.org
2021-02-05 10:15 ` jakub at gcc dot gnu.org
2021-02-08 18:51 ` jakub at gcc dot gnu.org
2021-02-09 11:33 ` cvs-commit at gcc dot gnu.org
2021-02-09 11:35 ` [Bug middle-end/98465] " jakub at gcc dot gnu.org
2021-02-19 23:41 ` msebor at gcc dot gnu.org
2021-11-12 19:53 ` msebor at gcc dot gnu.org
2022-02-15  3:55 ` Randy at miningrigrentals dot com
2022-02-15  9:47 ` redi at gcc dot gnu.org
2022-02-15  9:55 ` Randy at miningrigrentals dot com
2022-02-15 10:02 ` redi at gcc dot gnu.org
2022-02-15 10:50 ` Randy at miningrigrentals dot com [this message]
2022-02-15 12:29 ` redi at gcc dot gnu.org
2022-02-15 12:40 ` Randy at miningrigrentals dot com
2022-02-15 12:52 ` redi at gcc dot gnu.org
2022-02-15 19:23 ` Randy at miningrigrentals dot com
2022-02-17 10:37 ` 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-98465-4-kbdNvcIHUl@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).