http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48560
Summary: [4.6/4.7 Regression] -Warray-bounds fails to detect the out of bound array access Product: gcc Version: 4.7.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: middle-end AssignedTo: unassig...@gcc.gnu.org ReportedBy: hjl.to...@gmail.com [hjl@gnu-6 bfd]$ cat b.c char foo1 (int i) { static char s[] = "foo"; switch (i) { case 30: return s[30]; } return s[i]; } [hjl@gnu-6 bfd]$ /usr/gcc-4.5/bin/gcc -O3 -S -Wall b.c b.c: In function ‘foo1’: b.c:8:13: warning: array subscript is above array bounds [hjl@gnu-6 bfd]$ /usr/gcc-4.6/bin/gcc -O3 -S -Wall b.c [hjl@gnu-6 bfd]$