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

            Bug ID: 82044
           Summary: runtime signed integer overflow in
                    check_mem_read_rtx() and all_positions_needed_p() in
                    dse.c
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: msebor at gcc dot gnu.org
  Target Milestone: ---

When compiled with today's top of trunk (GCC 8.0) configured for x86_64-linux
--with-build-config=bootstrap-ubsan the following test case triggers a runtime
error in the check_mem_read_rtx() and all_positions_needed_p() functions in
dse.c.

$ cat t.c && gcc -O2 -S -Wall -ftracer t.c
typedef __SIZE_TYPE__ size_t;

extern void* memcpy (void* restrict, const void* restrict, size_t);

#define SSIZE_MAX   (__SIZE_MAX__ / 2)

void sink (void*);

void f (char *p, __SIZE_TYPE__ n)
{
  if (n < SSIZE_MAX - 2 || SSIZE_MAX < n)
    n = SSIZE_MAX - 2;

  memcpy (p, p + n, 3);
}
/src/gcc/git/gcc/dse.c:2122:18: runtime error: signed integer overflow: 1 +
9223372036854775807 cannot be represented in type 'long int'
/src/gcc/git/gcc/dse.c:1252:61: runtime error: shift exponent -1 is negative

Reply via email to