https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86889
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW Last reconfirmed| |2018-08-09 Ever confirmed|0 |1 --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- Thank you. With the small test case I can confirm the warning even on x86_64-linux. I've reduced it a tiny bit more. Here's the smaller test case and the VRP output: $ cat f.c && gcc -S -O2 -Wall -fdump-tree-vrp=/dev/stdout f.c struct a { long b[2]; }; int d (struct a *p) { int g = 1; for (; g >= 0; g--) if (p->b[g]) return g; __builtin_unreachable (); } ;; Function d (d, funcdef_no=0, decl_uid=1907, cgraph_uid=1, symbol_order=0) ;; 2 loops found ;; ;; Loop 0 ;; header 0, latch 1 ;; depth 0, outer -1 ;; nodes: 0 1 2 3 4 5 ;; 2 succs { 5 3 } ;; 3 succs { 5 4 } ;; 4 succs { 5 } ;; 5 succs { 1 } SSA replacement table N_i -> { O_1 ... O_j } means that N_i replaces O_1, ..., O_j p_9 -> { p_4(D) } Incremental SSA update started at block: 2 Number of blocks in CFG: 6 Number of blocks to update: 3 ( 50%) Value ranges after VRP: _1: VARYING p_4(D): VARYING g_5: [0, 1] _8: VARYING p_9: ~[0B, 0B] EQUIVALENCES: { p_4(D) } (1 elements) _11: VARYING f.c: In function ‘d’: f.c:8:13: warning: array subscript -1 is below array bounds of ‘long int[2]’ [-Warray-bounds] 8 | if (p->b[g]) | ~~~~^~~ d (struct a * p) { int g; long int _1; long int _8; long int _11; <bb 2> [local count: 357878152]: _8 = p_4(D)->b[1]; if (_8 != 0) goto <bb 5>; [33.33%] else goto <bb 3>; [66.67%] <bb 3> [local count: 238597364]: _11 = p_4(D)->b[0]; if (_11 != 0) goto <bb 5>; [33.33%] else goto <bb 4>; [66.67%] <bb 4> [local count: 159072864]: _1 = p_4(D)->b[-1]; <bb 5> [local count: 357878150]: # g_5 = PHI <-1(4), 1(2), 0(3)> return g_5; } ;; Function d (d, funcdef_no=0, decl_uid=1907, cgraph_uid=1, symbol_order=0) ;; 2 loops found ;; ;; Loop 0 ;; header 0, latch 1 ;; depth 0, outer -1 ;; nodes: 0 1 2 3 4 ;; 2 succs { 4 3 } ;; 3 succs { 4 } ;; 4 succs { 1 } SSA replacement table N_i -> { O_1 ... O_j } means that N_i replaces O_1, ..., O_j p_2 -> { p_4(D) } Incremental SSA update started at block: 2 Number of blocks in CFG: 5 Number of blocks to update: 2 ( 40%) Value ranges after VRP: _1: [0, +INF] p_2: ~[0B, 0B] EQUIVALENCES: { p_4(D) } (1 elements) p_4(D): VARYING g_5: [0, 1] _8: VARYING _9: [0, 1] _11: VARYING _12: [-1, 0] d (struct a * p) { int g; _Bool _1; long int _8; int _9; long int _11; int _12; <bb 2> [local count: 357878152]: _8 = p_4(D)->b[1]; if (_8 != 0) goto <bb 4>; [33.33%] else goto <bb 3>; [66.67%] <bb 3> [local count: 238597364]: _11 = p_4(D)->b[0]; _1 = _11 == 0; _9 = (int) _1; _12 = -_9; <bb 4> [local count: 357878150]: # g_5 = PHI <_12(3), 1(2)> return g_5; }