Using GCC 4.4.1 and the following command, test generates an "array subscript is above array bounds" warning.
gcc -S -Os test.c -Wall void foo (int b[2][6]) { int i = 0; for (i = 0; i < 6; i++) { int *pb = &b[1][i]; *pb = 0; } } Output from VRP looks like foo (int[6] * b) { int i; unsigned int D.1240; unsigned int i.0; <bb 2>: goto <bb 6>; <bb 3>: # i_16 = PHI <i_1(4), i_14(6)> i.0_6 = (unsigned int) i_16; D.1240_7 = i.0_6 + 6; (*b_4(D))[D.1240_7] = 0; <-- warning generated here i_10 = i_16 + 1; <bb 4>: # i_1 = PHI <i_10(3)> if (i_1 <= 5) goto <bb 3>; else goto <bb 5>; <bb 5>: return; <bb 6>: # i_14 = PHI <0(2)> goto <bb 3>; } In the statement (*b_4(D))[D.1240_7] = 0, range of b_4 appears to be [0 5] while the range of index D.1240_7 is [6 11]. -- Summary: incorrect "array subscript above bounds" warning Product: gcc Version: 4.4.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: rahul at icerasemi dot com GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45195