False positive from -Warray-bounds?

Ian Lance Taylor iant@google.com
Fri Dec 30 00:19:00 GMT 2011


Vincent Lefevre <vincent+gcc@vinc17.org> writes:

> The -Warray-bounds warning occurs with:
>
> void t(unsigned int s)
> {
>     arr1[f(s)] = 0;
>     arr1[f(s)] = 0;
> }
>
> but not with:
>
> void t(unsigned int s)
> {
>     arr1[f(s)] = 0;
> }
>
> If "The warning triggers if there is some code path in which the index
> is provably out of bounds." is the intended behavior (assuming that
> the warning phrasing isn't really correct), isn't this proof the same
> one in both cases? Why this difference in the gcc behavior?

Sounds like a bug somewhere to me.

The -Warray-bounds option is definitely optimization dependent, which is
a flaw.

Ian



More information about the Gcc-help mailing list