On Fri, Nov 13, 2009 at 1:09 PM, Matt <m...@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

Reply via email to