This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
False positive from -Warray-bounds?
- From: Lars Gullik BjÃnnes <larsbj at gullik dot org>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 29 Dec 2011 22:37:48 +0100
- Subject: False positive from -Warray-bounds?
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