1/* { dg-do compile } */
2/* { dg-options "-O2 -Wstrict-overflow=3" } */
3#if (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__)
4typedef unsigned long long ptrcast;
5#elif (__SIZEOF_LONG__ == __SIZEOF_POINTER__)
6typedef unsigned long ptrcast;
7#elif (__SIZEOF_INT__ == __SIZEOF_POINTER__)
8typedef unsigned int ptrcast;
9#else
10#error Add target support here
11#endif
12
13volatile unsigned long *
14sat_add(volatile unsigned long *ptr, unsigned long i, volatile unsigned long *end)
15{
16  if ((ptrcast)ptr + i * sizeof(*ptr) > (ptrcast)ptr) /* { dg-bogus "pointer wraparound" } */
17    return ptr + i;
18  else
19    return end;
20}
21
22
23