From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1618F3858D32; Thu, 25 May 2023 12:14:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1618F3858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685016871; bh=Iu2l8cyJWv2pze3oqV09gaGCuxrufD5cJIuI3jmtQjc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W85adfGEPG5q3oHuwGQJ/VSscPZUbzBsANqSiCqWlOdx6NkJ7imqHejWEO06m98i+ 4Wzz4vHaqLZJf0fxQL78fy0kB4dNjuuDlhBq317BfgbD9N00HUTW2q8xi1C8i8OZ7E HM1NstB75HTycGUociwCIoUMgrfy4njrP3Je3ZBc= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/109791] -Wstringop-overflow warning with -O3 and _GLIBCXX_USE_CXX11_ABI=0 Date: Thu, 25 May 2023 12:14:29 +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.1.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: rguenth 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=3D109791 --- Comment #14 from Richard Biener --- So one issue with the unfolding of PHIs is that for example gcc.dg/warn-sprintf-no-nul.c has const char a2[][3] =3D { "", "1", "12", "123", "123\000" }; and for # str_1 =3D PHI <&a2[2], &a2[3]> we can determine bounds on the string length of str_1 by unioning the string lengths of &a2[2] and &a2[3]. But with # off_2 =3D PHI <6, 9> str_1 =3D &a2 + off_2; this isn't possible. In fact get_range_strlen doesn't handle POINTER_PLUS_= EXPR and while it might be possible to handle "foo" + off_2 with looking at the range of off_2 for example the above case of refering to two different strings rather than offsetting within one string isn't distinguishable. I've also figured that when one PHI argument has zero offset (aka plain &a2) then PRE tends to undo the transform since &a2 + 0 is readily available on that edge and thus it inserts pointer adjustments on the other edges. So while it looked like the easy way out on the ranger limitation it's not a viable solution (because it regresses testcases).=