From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F2D04385DC0E; Mon, 13 Apr 2020 20:27:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F2D04385DC0E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1586809633; bh=ASqJo5/rdY199WlKA92BSFRNkpTMRVDnYSh4BltxUOE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ktM/ezYZxlUYnu46P1b+6Q/uaFrE/lypPvOVswlI8OZBjr9bnsBIYMo8usRXb59UD DMvYOQo5m6VHFTrMrAYQQNW1uvE0nTRHfvUXwgxK2mPTDuc1af6ZJbqjAQMHGHKMHO y+TVaP0nBnBUJlw2fh+u1yBmOC42x8X7dfwhhkEA= From: "msebor 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: Mon, 13 Apr 2020 20:27:13 +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: msebor 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: cf_known_to_work resolution blocked bug_status 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: Mon, 13 Apr 2020 20:27:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D81172 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Known to work| |10.0 Resolution|--- |FIXED Blocks| |56456 Status|NEW |RESOLVED --- Comment #6 from Martin Sebor --- 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 thi= nk this can be resolved as fixed. (There are plenty of other cases that still aren't diagnosed; please open new bugs for those if they aren't already bei= ng tracked under pr56456). $ cat pr81172.c && gcc -O2 -S -Wall pr81172.c int a[] =3D {1,2,3,4}; int* f (void) { int *p =3D a + 5; return p; } const char s[] =3D "aaa", t[] =3D "bbbbb"; const char* g (void) { const char *p =3D s + __builtin_strlen (t); return p; } 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"; | ^ Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D56456 [Bug 56456] [meta-bug] bogus/missing -Warray-bounds=