public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.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	[thread overview]
Message-ID: <bug-55079-4-EeQLpWZYlz@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-55079-4@http.gcc.gnu.org/bugzilla/>


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55079

--- Comment #13 from Richard Biener <rguenth at gcc dot gnu.org> 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.

>             abort ();
>         }
>     }
>   return curr + b;
> }
> 
> 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  
> t.c: In function ‘t’:
> t.c:14:2: warning: incompatible implicit declaration of built-in function
> ‘abort’ [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 = a[ix++];
>                ^
> t.c:19:15: warning: array subscript is above array bounds [-Warray-bounds]
> 
> Obivously here unroller does not know that bv_ix is at least 1


  parent reply	other threads:[~2012-12-10 14:14 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26  9:56 [Bug tree-optimization/55079] New: [4.8 regeression] false positive -Warray-bounds dimhen at gmail dot com
2012-10-26 10:09 ` [Bug tree-optimization/55079] " rguenth at gcc dot gnu.org
2012-10-30  9:34 ` [Bug tree-optimization/55079] [4.8 regression] " rguenth at gcc dot gnu.org
2012-10-30  9:35 ` rguenth at gcc dot gnu.org
2012-11-02 16:35 ` hubicka at gcc dot gnu.org
2012-11-02 16:47 ` hubicka at gcc dot gnu.org
2012-11-02 18:45 ` hubicka at gcc dot gnu.org
2012-11-02 20:51 ` hubicka at gcc dot gnu.org
2012-11-14 19:31 ` [Bug tree-optimization/55079] [4.8 regression] false positive -Warray-bounds (also seen at -O3 bootstrap) hubicka at gcc dot gnu.org
2012-11-15  1:01 ` hubicka at gcc dot gnu.org
2012-12-07 12:55 ` rguenth at gcc dot gnu.org
2012-12-10 13:23 ` rguenth at gcc dot gnu.org
2012-12-10 13:50 ` rguenth at gcc dot gnu.org
2012-12-10 14:14 ` rguenth at gcc dot gnu.org [this message]
2012-12-10 16:27 ` hubicka at ucw dot cz
2012-12-11 10:06 ` rguenth at gcc dot gnu.org
2012-12-11 10:08 ` rguenth at gcc dot gnu.org
2012-12-12  9:33 ` schwab at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-55079-4-EeQLpWZYlz@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).