view gcc/testsuite/gcc.dg/pr36227.c @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* { dg-do compile } */
/* { dg-options "-O2 -Wstrict-overflow=3" } */
#if (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__)
typedef unsigned long long ptrcast;
#elif (__SIZEOF_LONG__ == __SIZEOF_POINTER__)
typedef unsigned long ptrcast;
#elif (__SIZEOF_INT__ == __SIZEOF_POINTER__)
typedef unsigned int ptrcast;
#else
#error Add target support here
#endif

volatile unsigned long *
sat_add(volatile unsigned long *ptr, unsigned long i, volatile unsigned long *end)
{
  if ((ptrcast)ptr + i * sizeof(*ptr) > (ptrcast)ptr) /* { dg-bogus "pointer wraparound" } */
    return ptr + i;
  else
    return end;
}