http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55079
Bug #: 55079 Summary: [4.8 regeression] false positive -Warray-bounds Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassig...@gcc.gnu.org ReportedBy: dim...@gmail.com $ cat tst.c int f(unsigned len, int buflen) { unsigned taillen; unsigned slen; unsigned i; int b[17]; /* needed <= 17 to trigger Warning */ int j = 0; /* needed to trigger Warning */ b[0] = 0; taillen= buflen & 7; /* taillen [0..7] */ if(taillen) { /* taillen [1..7] */ slen= 8 - taillen; /* slen [7..1] */ if (len<slen) /* needed to trigger Warning */ slen=len; /* slen' < slen */ for(i=0; i<slen; i++) { j = b[taillen]; /* taillen + slen = [1..7] + [7..1] = 8 */ taillen++; } } return j; } $ gcc -Warray-bounds -c -O3 tst.c tst.c: In function 'f': tst.c:17:9: warning: array subscript is above array bounds [-Warray-bounds] j = b[taillen]; /* taillen + slen = [1..7] + [7..1] = 8 */ ^ gcc version 4.8.0 20121026 (experimental) [trunk revision 192837] (GCC) - if i remove some code then warning disappeared - why '18' is safe array top-bound?