This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/61942] New: loop-iv.c:2272 signed integer overflow


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

            Bug ID: 61942
           Summary: loop-iv.c:2272 signed integer overflow
           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 pr32349.c */
// gcc -funroll-loops -O3
// ../../gcc-4.9.1/gcc/loop-iv.c:2272:24: runtime error: 
// signed integer overflow: 9223372036854775807 - -9223372036854775808 cannot
be represented in type 'long int'
// offending instruction "nmax = INTVAL (mmax) - INTVAL (mmin);"
extern long *x1, *x2, *x3;

int
foo ()
{
  long *p1, *p2;
  long m, n, i;

  p1 = x1;
  p2 = x2;
  n = 0;
  for (i = *x3; 0 < i; i--)
    {
      m = (*p1++) ^ (*p2++);
      m = (m & 0x55555555) + ((m >> 1) & 0x55555555);
      n += m;
    }
  return n;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]