[Bug middle-end/69258] Flexible arrays break TBAA

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jan 13 12:01:00 GMT 2016


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

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
extern void abort (void);

struct Xflex { int n; int a[1]; };
struct Xspecific { int n; int a[7]; } x;

int __attribute__((noinline,noclone))
foo (struct Xflex *f)
{
  x.a[6] = 1;
  f->a[6] = 2;
  return x.a[6];
}

int __attribute__((noinline,noclone))
bar (struct Xflex *f)
{
  f->a[6] = 2;
  x.a[6] = 1;
  return f->a[6];
}

int main()
{
  if (foo ((struct Xflex *)&x) != 2)
    abort ();
  if (bar ((struct Xflex *)&x) != 1)
    abort ();
  return 0;
}


More information about the Gcc-bugs mailing list