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));
      |                                       
~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~

Reply via email to