https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113734
--- Comment #23 from Tamar Christina <tnfchris at gcc dot gnu.org> --- small standalone reducer: #include <string.h> #include <stdlib.h> #include <stdio.h> #define N 306 #define NEEDLE 136 __attribute__ ((noipa, noinline)) int use(int x[N]) { printf("res=%d\n", x[NEEDLE]); return x[NEEDLE]; } __attribute__ ((noipa, noinline)) int foo (int i, unsigned short parse_tables_n) { int table[N]; memset (table, -1, sizeof (table)); parse_tables_n >>= 9; parse_tables_n += 11; while (i < N && parse_tables_n--) table[i++] = 0; return use (table); } int main () { if (foo (0, 0xFFFF) != 0) abort (); return 0; } --- > gcc incorrect.c -O3 -o incorrect.exe; and ./incorrect.exe; echo $status res=-1 1 > gcc incorrect.c -O1 -o incorrect.exe; and ./incorrect.exe; echo $status res=0 0 > gcc incorrect.c -O3 -fdisable-tree-cunroll -o incorrect.exe; and > ./incorrect.exe; echo $status res=0 0