Wrong warnings "array subscript is above array bounds" are generated when compiling the given test case. warning: array subscript is above array bounds [-Warray-bounds]
1. Create a "test.c" file like the following:
/* test.c */
unsigned baz[6];
void test(unsigned *bar, unsigned n) {
unsigned i, j;
if (n > 6) {
n = 6;
}
for (i = 1; i < n; i++) {
for (j = i - 1; j > 0; j--) {
bar[j - 1] = baz[j - 1];
}
}
}
2. # $CC -m64 -O3 -S -Wall ~/test.c -o ~/test.o
warning: array subscript is above array bounds [-Warray-bounds]