From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 00FD9385840A; Tue, 29 Nov 2022 13:22:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 00FD9385840A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1669728125; bh=2+n5KRO0Jd/ySjolgwEfL6Lw6T8WL27Q3a7uPoU4i9M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hxbiylskf1SQ2yPOyJ65HIMYzV9CzKDefr7yorrjRTxQeQw2pJhQjJHy0Gj6RqN77 vqebAOLW7Q3fN1hjAvRaHeICYp585dlPezNeVKVe3Ge6Kcb1U76EF2a1jyLeE3FvSc tDkEPyyodRND0SVyqVNUr1MMxgqYJhMC9mv3JbwI= From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/107699] [12/13 Regression] False positive -Warray-bounds, non-existent offset reported by GCC Date: Tue, 29 Nov 2022 13:22:03 +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: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.3 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=3D107699 --- Comment #4 from Richard Biener --- At the point of the diagnostic we see [local count: 1073741824]: data._M_elems[0] =3D 3; data._M_elems[1] =3D 2; data._M_elems[2] =3D 1; _8 =3D getCount (); _1 =3D _8 * 4; _2 =3D &data._M_elems + _1; if (&data._M_elems !=3D _2) goto ; [53.47%] else goto ; [46.53%] that should possibly be optimized to if (_1 !=3D 0) but we cannot statically decide this jump. There's a later dynamic jump based on the very same _1, a check whether that's > 16, guarded by that we diagnose # .MEM_35 =3D VDEF <.MEM_34> std::__insertion_sort.isra (&data._M_elems, &MEM [(void *)&data + 64B]); where we complain about forming the (void *)&data + 64 address. I can't see a way to suppress the diagnostic completely but it should be possible to re-word it. Note using a global getCount without a conditional that this bound is inside 'data' bounds is not good programming practice.=