view gcc/testsuite/gcc.dg/pr63477.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents
children
line wrap: on
line source

/* 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];
    }
}