Created attachment 44967 [details] cc1plus bug.ii -O2 -W -Wall -quiet x86_64-linux --disable-checking bootstrap fails with: ../../../src/gcc/bitmap.c: In function ‘unsigned int bitmap_last_set_bit(const_bitmap)’: ../../../src/gcc/bitmap.c:1191:26: error: array subscript -1 is below array bounds of ‘const BITMAP_WORD [2]’ {aka ‘const long unsigned int [2]’} [-Werror=array-bounds] 1191 | word = elt->bits[ix]; | ~~~~~~~~~~~~^ Attached is a reduced testcase Adding: bitmap.o-warn = -Wno-error to gcc/Makefile.in works around the problem.
Author: nathan Date: Wed Nov 7 22:50:20 2018 New Revision: 265899 URL: https://gcc.gnu.org/viewcvs?rev=265899&root=gcc&view=rev Log: [PR/87936] --disable-checking bootstrap break https://gcc.gnu.org/ml/gcc-patches/2018-11/msg00502.html PR 87926 * Makefile.in (bitmap.o-warn): Add -Wno-error to unbreak --disable-checking bootstrap. Modified: trunk/gcc/ChangeLog trunk/gcc/Makefile.in
Please use -Wno-error=array-bounds instead of disabling _all_ errors.
Nathan: Can the bug be marked as resolved?
Marxin, the underlying problem is still there, I think
Author: nathan Date: Tue Nov 20 15:54:12 2018 New Revision: 266319 URL: https://gcc.gnu.org/viewcvs?rev=266319&root=gcc&view=rev Log: PR 87926 * Makefile.in (bitmap.o-warn): Use -Wno-error=array-bounds. Modified: trunk/gcc/ChangeLog trunk/gcc/Makefile.in
Confirmed. I _think_ I've seen a duplicate at some point. Given for (ix = 2 - 1; ix >= 0; ix--) { BITMAP_WORD word = elt->bits[ix]; if (word) goto found_bit; } __builtin_unreachable (); we compute that the loop exit test is never true (ix < 0) and thus elide it. That causes us to unroll the loop based on the size of elt->bits[] given that constrains the number of iterations now which is where we hit an older complete unrolling issue that it doesn't mark all unreachable bits properly unreachable. That is, remove_exits_and_undefined_stmts isn't doing it's job properly. Hmm, because a bound is recorded for the IV decrement (range info!) but not the load. Ah - trailing array. So the issue is indeed a dup of some PR because the IV already goes out of bound for the latch of the previous loop copy. Now go and find the dup... We can avoid the warning by refactoring the code to for (ix = 2 - 1; ix >= 1; ix--) { BITMAP_WORD word = elt->bits[ix]; if (word) goto found_bit; } gcc_assert (elt->bits[ix]); found_bit: return ix; which should be even faster eliding the read of elt->bits[0] for --disable-checking.