From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 9925D3858291; Mon, 29 Jan 2024 22:01:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9925D3858291 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1706565672; bh=jD7A3lyrt+5xeoUv9Hfu6Cf9oMDpDK+ARk/+2c/y0ak=; h=From:To:Subject:Date:In-Reply-To:References:From; b=rqO0CgXV79bJX1tqO9u2m1Xo53BCeQITJ3iQglf4yTTD8S3ES8KeHP84v44JWJgnp 35irPexGtRMKPcuUnNCgBmxSLRJcT3naloP59a9cQBmSegyx6DTteTD2viEPCECyDz Fo295QJ1YJ6PCxUEttnyW2sg+7+3fK5h8jdZ7W3U= From: "pinskia at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/113664] False positive warnings with -fno-strict-overflow (-Warray-bounds, -Wstringop-overflow) Date: Mon, 29 Jan 2024 22:01:12 +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 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=3D113664 --- Comment #1 from Andrew Pinski --- -fno-strict-overflow turns on -fwrapv-pointer which allows pointers to wrap which means if s was non-null, then `s+1` can be still a null pointer ... And then we go and prop null into dot and s is equal to null at that point.= and then we still generate the code for `*s++ =3D '.';` in ``` if (s =3D=3D dot) { *s++ =3D '.'; } ``` But it is `*NULL =3D '.';` due to that. The warning is very sensitive to the ability to optimization away null poin= ter checks in this case. Really `fno-strict-overflow` is normally to workaround some "undefinedness" in the code and the code should be improved to be fixe= d. Using -fwrapv instead also helps because now only signed integer overflows = and not also pointers ...=