PR middle-end/63477 - Bogus warning with -O3 -Warray-bounds: array subscript
[official-gcc.git] / gcc / testsuite / gcc.dg / pr63477.c
blob8fb2f266fd8362b3c1ddc086ee7ca4ad5a0d3a9e
1 /* PR middle-end/63477 - Bogus warning with -O3 -Warray-bounds: array
2 subscript is above array bounds
3 { dg-do compile }
4 { dg-options "-O3 -Warray-bounds" } */
6 #define MAX_VAL 16
8 typedef struct
10 int itemList[MAX_VAL + 1];
11 unsigned int numItems;
12 } ItemList;
14 void FrobList (ItemList *l)
16 unsigned int i;
18 for (i = 0; i < l->numItems - 1; i++)
20 int minVal = l->itemList[i];
22 unsigned int minIdx = i;
23 unsigned int idx;
25 for (idx = i + 1; idx < l->numItems; ++idx) {
27 if (l->itemList[idx] < minVal) /* { dg-bogus "\\\[-Warray-bounds]" } */
29 minVal = l->itemList[idx];
30 minIdx = idx;
34 l->itemList[i] = l->itemList[minIdx];