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

            Bug ID: 94940
           Summary: [10/11 Regression] array subscript i is outside array
                    bounds of ‘int[0]’ since r10-4300-g49fb45c81f4ac068
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Keywords: rejects-valid
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
                CC: msebor at gcc dot gnu.org
  Target Milestone: ---

It's a test-case reduced from qemu:

$ cat intelvf.i
struct a {
  int b;
  int d[0];
} e;

long int f;
int h();
void j(struct a *l) {
  int i;
  for (i = 0; l; i++)
    l->d[i] = 0;
}
int m() {
  int c = ({
    unsigned *k = (unsigned *)f;
    int g = h(k);
    g;
  });
  if (c)
    j(&e);
  return 0;
}

$ gcc -c -O2 -Werror=array-bounds intelvf.i
intelvf.i: In function ‘m’:
intelvf.i:11:9: error: array subscript i is outside array bounds of ‘int[0]’
[-Werror=array-bounds]
   11 |     l->d[i] = 0;
      |     ~~~~^~~
intelvf.i:3:7: note: while referencing ‘d’
    3 |   int d[0];
      |       ^
intelvf.i:4:3: note: defined here ‘e’
    4 | } e;
      |   ^
cc1: some warnings being treated as errors

Reply via email to