From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id B45683858C33; Fri, 31 Mar 2023 11:55:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B45683858C33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680263702; bh=BF5qR4j1raUv6rVCXeq5EwwDPcyXX7wLcfBhpbfzPE4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Ih5wQH72mQHmrNoV8mjWj7RI5KUlGoeDb6JbD+H+e82ZPlp5ay3X6wL4NDyUVduBb u+Y0DpHKHYnnEUMRKlFPPVHkEkpkjZ67ZI8kLWK2ylTynNRYJa5oDs2V9qcPlZLMc4 RDX7rioXrAG0vpbzitpiDr9cxcPT/Eb0Dsw/hbBM= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107087] [12/13 Regression] bits/stl_algobase.h:431: warning: 'void* __builtin_memcpy(void*, const void*, unsigned int)' reading between 8 and 2147483644 bytes from a region of size 4 [-Wstringop-overread] Date: Fri, 31 Mar 2023 11:55:02 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: REOPENED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: 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=3D107087 --- Comment #9 from Jonathan Wakely --- This prevents the warning: --- a/libstdc++-v3/include/bits/cow_string.h +++ b/libstdc++-v3/include/bits/cow_string.h @@ -911,13 +911,25 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// null-termination. size_type size() const _GLIBCXX_NOEXCEPT - { return _M_rep()->_M_length; } + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING =3D=3D 0 && __OPTIMIZE__ + if (_M_rep() =3D=3D &_S_empty_rep() && _M_rep()->_M_length !=3D 0) + __builtin_unreachable(); +#endif + return _M_rep()->_M_length; + } /// Returns the number of characters in the string, not including a= ny /// null-termination. size_type length() const _GLIBCXX_NOEXCEPT - { return _M_rep()->_M_length; } + { +#if _GLIBCXX_FULLY_DYNAMIC_STRING =3D=3D 0 && __OPTIMIZE__ + if (_M_rep() =3D=3D &_S_empty_rep() && _M_rep()->_M_length !=3D 0) + __builtin_unreachable(); +#endif + return _M_rep()->_M_length; + } /// Returns the size() of the largest possible %string. size_type=