From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4974 invoked by alias); 10 Dec 2012 14:14:39 -0000 Received: (qmail 4864 invoked by uid 48); 10 Dec 2012 14:14:13 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/55079] [4.8 regression] false positive -Warray-bounds (also seen at -O3 bootstrap) Date: Mon, 10 Dec 2012 14:14:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Priority: P1 X-Bugzilla-Assigned-To: rguenth at gcc dot gnu.org X-Bugzilla-Target-Milestone: 4.8.0 X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-12/txt/msg00991.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D55079 --- Comment #13 from Richard Biener 2012-12-10= 14:14:07 UTC --- (In reply to comment #9) > This is reduced testcase from gcov.c > int a[8]; > int > t (void) > { > int ix =3D 0; > int k; > int b =3D 0; > int curr =3D 0; > for (k =3D 0; k < 2; k++) > { > b =3D ix * 32; > curr =3D a[ix++]; > if (!(ix <=3D 8)) See below. > abort (); >=20 > while (curr) > { > b =3D ix * 32; > curr =3D a[ix++]; > if (!(ix <=3D 8)) This is a test after the fact. For ix =3D=3D 8 we will still enter the next loop iteration (GCC can't know anything about 'curr') and thus access a[8] which is out-of-bounds. Fixing the tests to test < 8 instead fixes the warnings. This testcase is invalid. > abort (); > } > } > return curr + b; > } >=20 > jan@linux-e0ml:~/trunk/build/gcc> ./xgcc -B ./ -O2 -fprofile-use t.c > -Warray-bounds -S -S -fdump-tree-cunroll-details -fdump-tree-all-details= =20=20 > t.c: In function =E2=80=98t=E2=80=99: > t.c:14:2: warning: incompatible implicit declaration of built-in function > =E2=80=98abort=E2=80=99 [enabled by default] > abort (); > ^ > t.c:25:1: note: file /home/jan/trunk/build/gcc/t.gcda not found, execution > counts estimated > } > ^ > t.c:19:15: warning: array subscript is above array bounds [-Warray-bounds] > curr =3D a[ix++]; > ^ > t.c:19:15: warning: array subscript is above array bounds [-Warray-bounds] >=20 > Obivously here unroller does not know that bv_ix is at least 1