From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9CACB3858D37; Thu, 20 Apr 2023 04:39:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9CACB3858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681965591; bh=hJkoMpKK9vu203q8EvRrgA5FYPp9aLQ8OSZ4lGQ+++E=; h=From:To:Subject:Date:From; b=wnRZ6KU8WIZfOV6cAGRTzCvd8oITz1J0ed2OQtTP5LWeC9SM5oGisIQ8KtC/4C8MQ BjJWcEkamvKvIXJmOKz/QodGin+ktjY41/RX/1GHaXclbsSdyQyrzlcs5D+U8FZwSr tLNpes0PASXKPL2CeR3giNIdIvKOqgktDI6lWnhw= From: "f.heckenbach@fh-soft.de" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109563] New: accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict] Date: Thu, 20 Apr 2023 04:39:51 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: f.heckenbach@fh-soft.de X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109563 Bug ID: 109563 Summary: accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1 may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict] Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: f.heckenbach@fh-soft.de Target Milestone: --- I'd like to know if the warning is bogus or the library actually accesses invalid memory. % cat test.cpp #include void f (const std::string &s) { "x" + std::string (s); } % g++ --std=3Dc++20 -O3 -Wall -c test.cpp In file included from /usr/include/c++/12/string:40, from test.cpp:1: In static member function =E2=80=98static constexpr std::char_traits:= :char_type* std::char_traits::copy(char_type*, const char_type*, std::size_t)=E2= =80=99, inlined from =E2=80=98static constexpr void std::__cxx11::basic_string<= _CharT, _Traits, _Alloc>::_S_copy(_CharT*, const _CharT*, size_type) [with _CharT = =3D char; _Traits =3D std::char_traits; _Alloc =3D std::allocator]= =E2=80=99 at /usr/include/c++/12/bits/basic_string.h:423:21, inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Allocator>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_M_replace(size_type, size_type, const _CharT*, size_type) [with _CharT =3D char; _Traits =3D std::char_traits; _Alloc =3D std::allocator]=E2=80=99 at /usr/include/c++/12/bits/basic_string.tcc= :532:22, inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::replace(size_type, size_type, const _CharT*, size_type) [with _Cha= rT =3D char; _Traits =3D std::char_traits; _Alloc =3D std::allocator]= =E2=80=99 at /usr/include/c++/12/bits/basic_string.h:2171:19, inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::insert(size_t= ype, const _CharT*) [with _CharT =3D char; _Traits =3D std::char_traits; _= Alloc =3D std::allocator]=E2=80=99 at /usr/include/c++/12/bits/basic_string.h:1= 928:22, inlined from =E2=80=98constexpr std::__cxx11::basic_string<_CharT, _Tra= its, _Allocator> std::operator+(const _CharT*, __cxx11::basic_string<_CharT, _Traits, _Allocator>&&) [with _CharT =3D char; _Traits =3D char_traits; _Alloc =3D allocator]=E2=80=99 at /usr/include/c++/12/bits/basic_stri= ng.h:3541:36, inlined from =E2=80=98void f(const std::string&)=E2=80=99 at test.cpp:5= :7: /usr/include/c++/12/bits/char_traits.h:431:56: warning: =E2=80=98void* __builtin_memcpy(void*, const void*, long unsigned int)=E2=80=99 accessing 9223372036854775810 or more bytes at offsets [2, 9223372036854775807] and 1= may overlap up to 9223372036854775813 bytes at offset -3 [-Wrestrict] 431 | return static_cast(__builtin_memcpy(__s1, __s2, __n)); |=