From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BA26E3858C41; Fri, 19 May 2023 04:37:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA26E3858C41 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1684471070; bh=sfVClB+LGrzW3iPdNoLDOuX7JUXPYmy4KwFMdt+VBT4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=imvfTIfxFp8ivma3qjTKcKf7WQ7L/JY3fGE1aSaIqjXrLTBsl/rZxPjtPCewp9THj VO9oaVK77emY3b91UeX6ES7a5FB8xHxHcr3PI1XpSc8rL34PmpGOxRsxCjOLSoBNsH WXA/PEmcd5dxk+uVIpaLRx9q2Z4bKecb9TmUUDrM= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107694] Bogus stringop-overflow warning in gcc 12 Date: Fri, 19 May 2023 04:37:50 +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.2.0 X-Bugzilla-Keywords: diagnostic 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: see_also 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=3D107694 Andrew Pinski changed: What |Removed |Added ---------------------------------------------------------------------------- See Also| |https://gcc.gnu.org/bugzill | |a/show_bug.cgi?id=3D109571 --- Comment #1 from Andrew Pinski --- PR 109571 is basically the same here just with a different warning (and upcasting instead of downcasting). In this case if we look at: void nsJSPrincipals::Destroy(JSPrincipals* jsprin) { nsJSPrincipals* nsjsprin =3D nsJSPrincipals::get(jsprin); if jsprin is null, then nsjsprin needs to be null too. And since nsjsprin = =3D=3D jsprin-8(bytes) (if it was a valid pointer), the C++ front-end needs to add= a check for null. And then the optimizations come along and does jump threadi= ng. so one way of removing this is adding an assumption which can be done via o= ne of the following: if (!jsprin) __builtin_unreachable(); [[assume(jsprin)]]; The first one is valid for GCC all the way back in 4.7 (and before). the second one is C++23 and was only added in GCC 13.=