From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 56ABE3850419; Mon, 8 Mar 2021 21:36:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 56ABE3850419 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/99474] New: missing warning on an out of bounds VLA access by a pointer Date: Mon, 08 Mar 2021 21:36:29 +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 21:36:29 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99474 Bug ID: 99474 Summary: missing warning on an out of bounds VLA access by a pointer 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: --- The out of bounds access in both functions below should be diagnosed by -Warray-bounds but only the first one is. $ cat v.c && gcc -O2 -S -Wall v.c void f (void*); void g (void) { int a[5]; int *p =3D &a[0]; p[5] =3D 0; // -Warray-bounds (good) f (a); } void h (int n) { if (n > 5) n =3D 5; int a[n]; int *p =3D &a[0]; p[5] =3D 0; // missing warning f (a); } v.c: In function =E2=80=98g=E2=80=99: v.c:7:4: warning: array subscript 5 is outside array bounds of =E2=80=98int= [5]=E2=80=99 [-Warray-bounds] 7 | p[5] =3D 0; // -Warray-bounds (good) | ~^~~ v.c:5:7: note: while referencing =E2=80=98a=E2=80=99 5 | int a[5]; | ^=