From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E6C803861971; Mon, 8 Mar 2021 22:32:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E6C803861971 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99475] New: [10/11 Regression] bogus -Warray-bounds accessing an array element of empty structs Date: Mon, 08 Mar 2021 22:32:33 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor 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: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 08 Mar 2021 22:32:34 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99475 Bug ID: 99475 Summary: [10/11 Regression] bogus -Warray-bounds accessing an array element of empty structs Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- An indirect access to an element of an array of empty structs through a poi= nter to such an element triggers a spurious -Warray-bounds warning: $ cat v.c && gcc -O2 -S -Wall v.c struct S { } a[5]; void f (void) { a[1] =3D (struct S) { }; // okay } void g (void) { struct S *p =3D &a[0]; p[1] =3D (struct S) { }; // bogus -Warray-bounds } v.c: In function =E2=80=98g=E2=80=99: v.c:11:4: warning: array subscript 0 is outside array bounds of =E2=80=98st= ruct S[5]=E2=80=99 [-Warray-bounds] 11 | p[1] =3D (struct S) { }; | ~^~~ v.c:1:14: note: while referencing =E2=80=98a=E2=80=99 1 | struct S { } a[5]; | ^=