public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* False positive from -Warray-bounds?
@ 2011-12-29 22:02 Lars Gullik Bjønnes
  2011-12-29 22:45 ` Ian Lance Taylor
  2011-12-29 23:17 ` Vincent Lefevre
  0 siblings, 2 replies; 14+ messages in thread
From: Lars Gullik Bjønnes @ 2011-12-29 22:02 UTC (permalink / raw)
  To: gcc-help

I have this code:

--------------
unsigned int f(unsigned int value)
{
    unsigned int i = (value & 0xffff);
    return (i == 0xffff ? 0xffffffff : i);
}


static int *arr1[10];

void t(unsigned int s)
{
    arr1[f(s)] = 0;
    arr1[f(s)] = 0;
}
------------------


When compiled with 'gcc -Wall -Wextra -c' I get a warning about
"subscript is above array bounds".
Shouldn't the -Warray-bounds only warn if will _always_ be out-of-bounds?

Is this a false positive, or is there something that I am completely missing?

I see this with gcc from trunk (some days ago), and with redhat gcc 4.6.2-1.

-- 
        Lgb

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2011-12-30 12:08 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-29 22:02 False positive from -Warray-bounds? Lars Gullik Bjønnes
2011-12-29 22:45 ` Ian Lance Taylor
2011-12-29 23:03   ` Lars Gullik Bjønnes
2011-12-29 23:57     ` Ian Lance Taylor
2011-12-30  0:16       ` Vincent Lefevre
2011-12-30  0:21         ` Vincent Lefevre
2011-12-30  0:38         ` Ian Lance Taylor
2011-12-30  5:00           ` Vincent Lefevre
2011-12-30  8:29             ` Ian Lance Taylor
2011-12-30 12:08               ` David Brown
2011-12-30 19:44                 ` Vincent Lefevre
2011-12-29 23:24   ` Vincent Lefevre
2011-12-30  0:19     ` Ian Lance Taylor
2011-12-29 23:17 ` Vincent Lefevre

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).