From: Martin Sebor Date: Thu, 16 Nov 2017 16:48:36 +0000 (+0000) Subject: PR middle-end/63477 - Bogus warning with -O3 -Warray-bounds: array subscript X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=913f8c088eb3b2d6e2c7a55954de4e0c38d78766;p=gcc.git PR middle-end/63477 - Bogus warning with -O3 -Warray-bounds: array subscript PR middle-end/63477 - Bogus warning with -O3 -Warray-bounds: array subscript is above array bounds gcc/testsuite/ChangeLog: PR middle-end/63477 * gcc.dg/pr63477.c: New test. From-SVN: r254833 --- diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 30082bf1821..a932323e5d3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2017-11-16 Martin Sebor + + PR middle-end/63477 + * gcc.dg/pr63477.c: New test. + 2017-11-16 Martin Sebor PR tree-optimization/82588 diff --git a/gcc/testsuite/gcc.dg/pr63477.c b/gcc/testsuite/gcc.dg/pr63477.c new file mode 100644 index 00000000000..8fb2f266fd8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr63477.c @@ -0,0 +1,36 @@ +/* PR middle-end/63477 - Bogus warning with -O3 -Warray-bounds: array + subscript is above array bounds + { dg-do compile } + { dg-options "-O3 -Warray-bounds" } */ + +#define MAX_VAL 16 + +typedef struct +{ + int itemList[MAX_VAL + 1]; + unsigned int numItems; +} ItemList; + +void FrobList (ItemList *l) +{ + unsigned int i; + + for (i = 0; i < l->numItems - 1; i++) + { + int minVal = l->itemList[i]; + + unsigned int minIdx = i; + unsigned int idx; + + for (idx = i + 1; idx < l->numItems; ++idx) { + + if (l->itemList[idx] < minVal) /* { dg-bogus "\\\[-Warray-bounds]" } */ + { + minVal = l->itemList[idx]; + minIdx = idx; + } + } + + l->itemList[i] = l->itemList[minIdx]; + } +}