This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Warray-bounds false negative


On Fri, 13 Nov 2009, Andrew Pinski wrote:

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];

d'oh! Next time I'll look at the objdump output first.


Thanks for the quick explanation!

--
tangled strands of DNA explain the way that I behave.
http://www.clock.org/~matt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]