From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1C1F83857C55; Wed, 14 Oct 2020 17:22:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1C1F83857C55 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/97425] New: bogus array bounds in -Warray-bounds for a function array parameter Date: Wed, 14 Oct 2020 17:22:19 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: minor 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: Wed, 14 Oct 2020 17:22:20 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97425 Bug ID: 97425 Summary: bogus array bounds in -Warray-bounds for a function array parameter Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: minor Priority: P3 Component: middle-end Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- The -Wartray-bounds warnings in the test case below are all expected but the bounds of the array types referenced in the messages for f3 and and f4 don't correspond to those in the array parameters. In f3 the warning should mention =E2=80=98int[2][3][4]=E2=80=99 instead and= in f4 it should reference =E2=80=98int[1][2][3][4]=E2=80=99. $ cat z.c && gcc -O2 -S -Wall z.c void f1 (int a[4]) { int *p =3D &a[0]; p[4] =3D 0; } void f2 (int a[3][4]) {=20 int *p =3D &a[0][0]; p[3 * 4] =3D 0; } void f3 (int a[2][3][4]) { int *p =3D &a[0][0][0]; p[2 * 3 * 4] =3D 0; } void f4 (int a[1][2][3][4]) { int *p =3D &a[0][0][0][0]; p[1 * 2 * 3 * 4] =3D 0; } z.c: In function =E2=80=98f1=E2=80=99: z.c:4:4: warning: array subscript 4 is outside array bounds of =E2=80=98int= [4]=E2=80=99 [-Warray-bounds] 4 | p[4] =3D 0; | ~^~~ z.c:1:14: note: while referencing =E2=80=98a=E2=80=99 1 | void f1 (int a[4]) | ~~~~^~~~ z.c: In function =E2=80=98f2=E2=80=99: z.c:10:4: warning: array subscript 12 is outside array bounds of =E2=80=98i= nt[3]=E2=80=99 [-Warray-bounds] 10 | p[3 * 4] =3D 0; | ~^~~~~~~ z.c:7:14: note: while referencing =E2=80=98a=E2=80=99 7 | void f2 (int a[3][4]) | ~~~~^~~~~~~ z.c: In function =E2=80=98f3=E2=80=99: z.c:16:4: warning: array subscript 24 is outside array bounds of =E2=80=98i= nt[2][4]=E2=80=99 [-Warray-bounds] 16 | p[2 * 3 * 4] =3D 0; | ~^~~~~~~~~~~ z.c:13:14: note: while referencing =E2=80=98a=E2=80=99 13 | void f3 (int a[2][3][4]) | ~~~~^~~~~~~~~~ z.c: In function =E2=80=98f4=E2=80=99: z.c:16:16: warning: array subscript 24 is outside array bounds of =E2=80=98int[1][3][4]=E2=80=99 [-Warray-bounds] 16 | p[2 * 3 * 4] =3D 0; | ~~~~~~~~~~~~~^~~ z.c:19:14: note: while referencing =E2=80=98a=E2=80=99 19 | void f4 (int a[1][2][3][4]) | ~~~~^~~~~~~~~~~~~=