With Debian's gcc-snapshot 20150722-1 on the following program, I get an incorrect warning "array subscript is above array bounds". unsigned char buffer[8]; unsigned long foo (void) { unsigned long i; i = buffer[0]; if (i >= 8) return i - 7; i++; while (i > 8) { if (buffer[i-1] != 0) return 0; i--; } return 1; } zira:~> gcc-snapshot -Wall -O2 -c tst.c tst.c: In function 'foo': tst.c:11:17: warning: array subscript is above array bounds [-Warray-bounds] if (buffer[i-1] != 0) ^ I don't get this warning if I use -O1 or gcc-snapshot 20150701-1 (thus this problem is very recent) or GCC 5.1.1 (gcc-5 Debian package). Notes: * There are other bugs concerning this warning, but they are older, while here this is a recent regression. * The above code has been obtained by simplifying MPFR's mpfr_fpif_read_precision_from_file function in fpif.c (trunk).
I believe this has been fixed with 2015-07-23 Richard Biener <rguenther@suse.de> PR middle-end/66916 * match.pd: Guard widen and sign-change comparison simplification with single_use.
Author: hjl Date: Mon Aug 3 16:58:03 2015 New Revision: 226518 URL: https://gcc.gnu.org/viewcvs?rev=226518&root=gcc&view=rev Log: Add a testcase for PR tree-optimization/67077 PR tree-optimization/67077 * gcc.dg/pr67077.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr67077.c Modified: trunk/gcc/testsuite/ChangeLog