Commit 913f8c08 by Martin Sebor Committed by Martin Sebor

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
parent b00ff621
2017-11-16 Martin Sebor <msebor@redhat.com>
PR middle-end/63477
* gcc.dg/pr63477.c: New test.
2017-11-16 Martin Sebor <msebor@redhat.com>
PR tree-optimization/82588
PR tree-optimization/82583
* c-c++-common/Warray-bounds.c: New test.
......
/* 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];
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment