From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 4020C385DC03; Tue, 14 Apr 2020 05:58:49 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4020C385DC03 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586843929; bh=81R+X+3lTgcLFAiDY09SHlGSvmPxh3HM77LA8eCJOQE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ec51usen7yQn9ZRg8wlBLhjOAUOJrgl4yy8Ou5bAlOVDJMoI/7uiRnJmZ6cYYM7fG 7ChPU4M1Y9TjIn5DWicRo5jBWT4jnXw1GOZYc9IVrOx741AsSm8KWb4/oSfLbQ5pT0 NcMkjMcp9kf1DkEqTNagNlmi6ZLmThWMOE06ASSc= From: "egallager at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/81172] Expected new warning option -Warray-bounds-pointer-arithmetic Date: Tue, 14 Apr 2020 05:58:49 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 8.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: egallager at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Resolution: FIXED 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: cc 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 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: Tue, 14 Apr 2020 05:58:49 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D81172 Eric Gallager changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |egallager at gcc dot gnu.o= rg --- Comment #7 from Eric Gallager --- (In reply to Martin Sebor from comment #6) > For the slightly modified test case GCC 10 issues the expected warnings in > the expected cases (i.e., unless the code is removed as unused, etc.) So= I > think this can be resolved as fixed. (There are plenty of other cases th= at > still aren't diagnosed; please open new bugs for those if they aren't > already being tracked under pr56456). >=20 > $ cat pr81172.c && gcc -O2 -S -Wall pr81172.c >=20 > int a[] =3D {1,2,3,4}; >=20 > int* f (void) > { > int *p =3D a + 5; > return p; > } >=20 > const char s[] =3D "aaa", t[] =3D "bbbbb"; >=20 > const char* g (void) > { > const char *p =3D s + __builtin_strlen (t); > return p; > } >=20 > const char* h (void) > { > return s + 'c'; > } > pr81172.c: In function =E2=80=98f=E2=80=99: > pr81172.c:5:8: warning: array subscript 5 is outside array bounds of > =E2=80=98int[4]=E2=80=99 [-Warray-bounds] > 5 | int *p =3D a + 5; > | ^ > pr81172.c:1:5: note: while referencing =E2=80=98a=E2=80=99 > 1 | int a[] =3D {1,2,3,4}; > | ^ > pr81172.c: In function =E2=80=98g=E2=80=99: > pr81172.c:13:15: warning: array subscript 5 is outside array bounds of > =E2=80=98const char[4]=E2=80=99 [-Warray-bounds] > 13 | const char *p =3D s + __builtin_strlen (t); > | ^ > pr81172.c:9:12: note: while referencing =E2=80=98s=E2=80=99 > 9 | const char s[] =3D "aaa", t[] =3D "bbbbb"; > | ^ > pr81172.c: In function =E2=80=98h=E2=80=99: > pr81172.c:19:12: warning: array subscript 99 is outside array bounds of > =E2=80=98const char[4]=E2=80=99 [-Warray-bounds] > 19 | return s + 'c'; > | ~~^~~~~ > pr81172.c:9:12: note: while referencing =E2=80=98s=E2=80=99 > 9 | const char s[] =3D "aaa", t[] =3D "bbbbb"; > | ^ I'd think breaking this into a separate sub-option as previously suggested would still be useful; I can see people wanting other -Warray-bounds warnin= gs but not these, and vice versa=