http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60115

--- Comment #1 from Zhendong Su <su at cs dot ucdavis.edu> ---
The reported testcase seems to reveal an independent issue: GCC does warn the
out-of-bound array access at -Os and above, but not at -O0 and -O1, while clang
warns at all optimization levels. 

$ gcc-trunk -Warray-bounds -O0 small.c
$ gcc-trunk -Warray-bounds -O1 small.c 
$     
$ gcc-trunk -Warray-bounds -Os small.c
small.c: In function ‘main’:
small.c:8:10: warning: array subscript is above array bounds [-Warray-bounds]
     if (b[613])
          ^
$
$ clang-trunk -Warray-bounds -O0 small.c
small.c:8:9: warning: array index 613 is past the end of the array (which
contains 1 element) [-Warray-bounds]
    if (b[613])
        ^ ~~~
small.c:1:1: note: array 'b' declared here
int a, b[1];
^
1 warning generated.
$

Reply via email to