From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 6F9953858C30; Wed, 31 May 2023 23:38:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F9953858C30 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685576332; bh=rMCjrGyudgoQ8xbtGJWeRbXCr6JgmZKEhx/WmJZbToQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rYyEvtKb/rgBEjjYdRn2ArSHMI0MbGZcc5XQ/+uDJc4yIWnpzPnz2piYutK1ertBQ dqfB92Cm6AgiNfvXAaZdXZ1zUIRyw5bZ+AXgbwoH21qAWPh0WkOEL66Vu2ByFzfKV1 JtOV0R4ZtiGGjSJpIfRaebFBlw01p3lUqyhD2s3M= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/110060] Adding optimizer hints to std::vector causes a new -Wstringop-overread false positive Date: Wed, 31 May 2023 23:38:52 +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: 14.0 X-Bugzilla-Keywords: diagnostic, missed-optimization X-Bugzilla-Severity: normal X-Bugzilla-Who: pinskia at gcc dot gnu.org 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: 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=3D110060 --- Comment #6 from Andrew Pinski --- Note you can reduce main to just: ``` int main() { std::vector v(5); const std::vector w(1); v.resize(1); // v.insert(v.begin(), 0); //v.insert(v.begin(), 1, 0); // v.insert(v.begin(), w.begin(), w.end()); v =3D w; return 0; } ``` And get the warning still at -O2. With the above main in .optimized we get: ``` MEM[(struct _Vector_base *)&w]._M_impl.D.25239._M_start =3D _53; _46 =3D _53 + 4; MEM[(struct _Vector_base *)&w]._M_impl.D.25239._M_end_of_storage =3D _46; *_53 =3D 0; w.D.25935._M_impl.D.25239._M_finish =3D _46; v.D.25935._M_impl.D.25239._M_finish =3D __first_33; __xlen_82 =3D std::vector::size (&w); if (__xlen_82 > 5) goto ; [33.00%] else goto ; [67.00%] ``` std::vector::size is literally just: ``` movq 8(%rdi), %rax subq (%rdi), %rax sarq $2, %rax ret ``` So that is definitely an issue there.=