From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 85949385AC22; Thu, 21 Apr 2022 11:15:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85949385AC22 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/105329] Bogus restrict warning when assigning 1-char string literal to std::string Date: Thu, 21 Apr 2022 11:15:51 +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: 12.0 X-Bugzilla-Keywords: diagnostic, missed-optimization, needs-bisection X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW 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: everconfirmed cc component bug_status keywords cf_reconfirmed_on 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Apr 2022 11:15:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105329 Richard Biener changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 CC| |amacleod at redhat dot com Component|c++ |tree-optimization Status|UNCONFIRMED |NEW Keywords| |diagnostic, | |missed-optimization, | |needs-bisection Last reconfirmed| |2022-04-21 --- Comment #1 from Richard Biener --- It warns about __builtin_memcpy (_140, _29, _28); in [local count: 14831835]: __nleft_49 =3D (const size_type) _48; __builtin_memcpy (_22, "5", __nleft_49); _28 =3D 1 - __nleft_49; _29 =3D _22 + 1; _140 =3D _22 + __nleft_49; __builtin_memcpy (_140, _29, _28); pretmp_145 =3D MEM[(const struct basic_string *)s_2(D)]._M_dataplus._M_p; goto ; [100.00%] the block is guarded with if (_22 >=3D &MEM [(void *)"5" + 1B]) goto ; [50.00%] else goto ; [50.00%] if (_22 <=3D "5") goto ; [50.00%] else goto ; [50.00%] [local count: 22472477]: _48 =3D _22 - "5"; if (_48 =3D=3D 1) goto ; [34.00%] else goto ; [66.00%] so we're taking the path where "5" is not one character in size. We should have somehow simplified this. It looks like a missed jump-threading, not sure if we were able to catch this with the forward threader or the old VRP.=