From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D4B303857C59; Tue, 13 Sep 2022 06:44:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4B303857C59 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1663051495; bh=1lOo3Ga7I/m6tmtKhZiH/aXhvB92N/QjSMcBB3Iugjk=; h=From:To:Subject:Date:From; b=K6yppNlDtChw3WvInuRCCpeKCtJjzErKZGsgGUhSKcasuceIPkb9yAiaXFXlE2YK6 Ss6WFjnoKg8KsqESBldsTPky2+gMZZnK2A5rCQISDkXJezv/Y6gMdWOWEJKUt/Xz7J LGiUd1MhhSExwblJeaxfcYZ6IBVYkW4yDbfg5TY8= From: "npfhrotynz-ptnqh.myvf at noclue dot notk.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/106920] New: -Warray-bound false positive regression with -O2 or -Os Date: Tue, 13 Sep 2022 06:44:55 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 12.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: npfhrotynz-ptnqh.myvf at noclue dot notk.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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D106920 Bug ID: 106920 Summary: -Warray-bound false positive regression with -O2 or -Os Product: gcc Version: 12.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: npfhrotynz-ptnqh.myvf at noclue dot notk.org Target Milestone: --- Hello, I think I've run into a false positive on this file: https://source.codeaurora.org/external/imx/imx-atf/tree/plat/imx/imx8m/hab.= c?h=3Dlf_v2.6 I could trim it down to this ---- #include typedef void hab_rvt_entry_t(void); int main() { hab_rvt_entry_t *a; a =3D ((hab_rvt_entry_t *)(*(unsigned long *)(0x908))); a(); return 0; } ---- $ gcc -O2 -Warray-bounds -c t.c t.c: In function =E2=80=98main=E2=80=99: t.c:7:34: warning: array subscript 0 is outside array bounds of =E2=80=98lo= ng unsigned int[0]=E2=80=99 [-Warray-bounds] 7 | a =3D ((hab_rvt_entry_t *)(*(unsigned long *)(0x908))); | ~^~~~~~~~~~~~~~~~~~~~~~~~~~ ---- According to godbolt this passed on 11.3 and starts emitting the warning on 12.1 (it doesn't have 12.0) and still emits it on trunk. Note the warning requires -O2, -O3 or -Os to be emitted. The problem seems to be that it considers an arbitrary address casted to u6= 4* to be a u64[0] ? If so that might be a problem for quite a few embedded products as that is quite common when dealing with hardware registers. (and who doesn't love products that compile with -Werror for release builds= ...) Thanks!=