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

            Bug ID: 62058
           Summary: Undefined behaviour in tree-data-ref.c with options
                    -O1 -ftree-loop-vectorize
           Product: gcc
           Version: 4.9.1
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zeccav at gmail dot com

/* from testsuite p60183.c */
/* gcc 4.9.1 -S -O1 -ftree-loop-vectorize */
/* ../../gcc-4.9.1/gcc/tree-data-ref.c:2423:16: runtime error: signed integer
overflow: 65536 * -65536 cannot be represented in type 'int' */
/* ../../gcc-4.9.1/gcc/tree-data-ref.c:2334:38: runtime error: signed integer
overflow: 1073741824 + 1073741824 cannot be represented in type 'int' */
/* ../../gcc-4.9.1/gcc/tree-data-ref.c:2425:16: runtime error: negation of
-2147483648 (INT_MIN) cannot be represented in type 'int'; cast to an unsigned
type to negate this value to itself */
/* ../../gcc-4.9.1/gcc/tree-data-ref.c:2424:16: runtime error: negation of
-2147483648 (INT_MIN) cannot be represented in type 'int'; cast to an unsigned
type to negate this value to itself */
/* on x86-64 from testsuite pr60183.c */
unsigned char c[0x30001] = { 1 };
int j = 0; /* independent of the j initialization value */ 

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 += 0x10000;
      w += *y;
    }
  x[1] = w;
}

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

Reply via email to