This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug tree-optimization/59124] [4.9/5/6 Regression] Wrong warnings "array subscript is above array bounds"


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124

--- Comment #37 from Domani Hannes <ssbssa at yahoo dot de> ---
With the new patch there is still a warning with this example:
=============== 8< ===============
int f(void);

int test(void)
{
  int baz[4];
  int q = 0;
  int d, i, j, sum;

  for (i = 0; i < 2; i++)
  {
    d = f();

    if (d == 3)
    {
      baz[q] = d;
      q++;
      if (q == 4) break;
    }
  }

  sum = 0;
  for (i = 0; i < q; i++)
  {
    for (j = i + 1; j < q; j++)
    {
      sum += baz[j];
    }
  }

  return (sum);
}
=============== >8 ===============
$ gcc -O3 -Wall -S q.c
q.c: In function 'test':
q.c:27:17: warning: array subscript is above array bounds [-Warray-bounds]
       sum += baz[j];
                 ^

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]