http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60183

--- Comment #2 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Updated testcase that segfaults for me, no -fsanitize=address is then needed to
trigger it.  Works with -O0 or -O? -fno-tree-phiprop:

unsigned char c[0x300001] = { 1 };
int j = 2;

static void
foo (unsigned long *x, unsigned char *y)
{
  int i;
  unsigned long w = x[0];
  for (i = 0; i < j; i++)
    {
      w += *y;
      y += 0x100000;
      w += *y;
      y += 0x100000;
    }
  x[1] = w;
}

__attribute__ ((noinline, noclone)) void
bar (unsigned long *x)
{
  foo (x, c);
}

int
main ()
{
  unsigned long a[2] = { 0, -1UL };
  asm volatile (""::"r" (c):"memory");
  c[0] = 0;
  bar (a);
  if (a[1] != 0)
    __builtin_abort ();
  return 0;
}

Perhaps phiprop is confused by the &MEM[(void *)y_5 + 2097152B] and thinks that
because of the MEM_REF in there it is safe to dereference it?

Reply via email to