False positive from -Warray-bounds?

Vincent Lefevre vincent+gcc@vinc17.org
Thu Dec 29 23:17:00 GMT 2011


On 2011-12-29 22:37:48 +0100, Lars Gullik Bjønnes wrote:
> I have this code:
> 
> --------------
> unsigned int f(unsigned int value)
> {
>     unsigned int i = (value & 0xffff);
>     return (i == 0xffff ? 0xffffffff : i);
> }
> 
> 
> static int *arr1[10];
> 
> void t(unsigned int s)
> {
>     arr1[f(s)] = 0;
>     arr1[f(s)] = 0;
> }
> ------------------
> 
> 
> When compiled with 'gcc -Wall -Wextra -c' I get a warning about
> "subscript is above array bounds".

Under Debian, one also needs the -O2 option to make the warning appear.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)



More information about the Gcc-help mailing list