This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: -Warray-bounds false negative
- From: Andrew Pinski <pinskia at gmail dot com>
- To: Matt <matt at use dot net>
- Cc: gcc at gcc dot gnu dot org
- Date: Fri, 13 Nov 2009 13:15:47 -0800
- Subject: Re: -Warray-bounds false negative
- References: <Pine.NEB.4.64.0911131303560.24472@cesium.clock.org>
On Fri, Nov 13, 2009 at 1:09 PM, Matt <matt@use.net> wrote:
> Hello,
>
> I recently came across a false negative in GCC's detection of array bounds
> violation. At first, I thought the other tool (PC-Lint) was having false
> positive, but it turns out to be correct. The false negative occurs in GCC
> 4.3, 4.4.1, and latest trunk (4.5). I'm curious to understand how exactly
> the detection breaks down, as I think it may affect if/how the loop in
> question is optimized.
Well in this case, all of the code is considered dead is removed
before the warning will happen to be emitted.
If I change it so that data is read from (instead of just written to),
the trunk warns about this code:
t.c:21:20: warning: array subscript is above array bounds
I changed the last return to be:
return data[2];
Thanks,
Andrew Pinski