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

--- Comment #22 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Self-contained testcase which actually fails because of this bug, even e.g.
when compiled with -O0 and gcc 8.2.1.  That doesn't mean this bug shouldn't be
P1, because preventing bootstrap on a primary target is extremely severe.

struct S { int a, b, c; int *d; };
struct T { int *e, *f, *g; } *t = 0;
int *o = 0;

__attribute__((noipa))
void bar (int *x, int y, int z, int w)
{
  if (w == -1)
    {
      if (x != 0 || y != 0 || z != 0)
        __builtin_abort ();
    }
  else if (w != 0 || x != t->g || y != 0 || z != 12)
    __builtin_abort ();
}

__attribute__((noipa)) void
foo (struct S *x, struct S *y, int *z, int w)
{
  *o = w;
  if (w)
    bar (0, 0, 0, -1);
  x->d = z;
  if (y->d)
    y->c = y->c + y->d[0];
  bar (t->g, 0, y->c, 0);
}

int
main ()
{
  int a[4] = { 8, 9, 10, 11 };
  struct S s = { 1, 2, 3, &a[0] };
  struct T u = { 0, 0, &a[3] };
  o = &a[2];
  t = &u;
  foo (&s, &s, &a[1], 5);
  if (s.c != 12 || s.d != &a[1])
    __builtin_abort ();
  return 0;
}

Reply via email to