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: odd array subscript is above array bounds error


2009/3/5 Dave Korn <dave.korn.cygwin@googlemail.com>:
>
> of an array that only has size[4] is going one past the end. ?So the bug is
> the missing warning for the simplified testcase, not that the warning is
> somehow incorrect in the more complex one.

No. The array is unused so it gets removed quite early. If you *do*
return the array, then the warning appears. There is no bug here
(except we could warn for unused array, that would be nice... if you
wish to open a PR for that).

> ?I would hope that in the simpler case the entire unused local array gets
> optimised away, and the loop and 'a' go with it. ?That might explain why
> there's no sign of an error. ?But your testcase invokes invalid behaviour, so
> there's no reason why the compiler shouldn't handle it in differing and
> inconsistent ways at different optimisation levels.

In fact the simple local array gets removed by the moment we reach 034t.sdse.

Cheers,

Manuel.


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