From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7714 invoked by alias); 10 Dec 2012 16:27:27 -0000 Received: (qmail 6640 invoked by uid 55); 10 Dec 2012 16:26:50 -0000 From: "hubicka at ucw dot cz" 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 16:27: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: hubicka at ucw dot cz 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" 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/msg01004.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55079 --- Comment #14 from Jan Hubicka 2012-12-10 16:26:40 UTC --- > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55079 > > --- 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 = 0; > > int k; > > int b = 0; > > int curr = 0; > > for (k = 0; k < 2; k++) > > { > > b = ix * 32; > > curr = a[ix++]; > > if (!(ix <= 8)) > > See below. > > > abort (); > > > > while (curr) > > { > > b = ix * 32; > > curr = a[ix++]; > > if (!(ix <= 8)) > > This is a test after the fact. For ix == 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. I fixed that in GCOV sources already, but it depends on the definition of invalidness. In general construct like ix <= some_constant may come from some unrelated stuff (macro expansion) and may be fully redundant in sane and valid program. In that case waring after unrolling some_constant times there will be out of bound access (without explicitely saying that unrolling is needed) is undesirable IMO. The loop has other exit that takes care of the proper bound. Honza