2015-09-24 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.dg / pr36227.c
blob27fe00155059326e0cfab063ab6e2c3bf332d95d
1 /* { dg-do compile } */
2 /* { dg-options "-O2 -Wstrict-overflow=3" } */
3 #if (__SIZEOF_LONG_LONG__ == __SIZEOF_POINTER__)
4 typedef unsigned long long ptrcast;
5 #elif (__SIZEOF_LONG__ == __SIZEOF_POINTER__)
6 typedef unsigned long ptrcast;
7 #elif (__SIZEOF_INT__ == __SIZEOF_POINTER__)
8 typedef unsigned int ptrcast;
9 #else
10 #error Add target support here
11 #endif
13 volatile unsigned long *
14 sat_add(volatile unsigned long *ptr, unsigned long i, volatile unsigned long *end)
16 if ((ptrcast)ptr + i * sizeof(*ptr) > (ptrcast)ptr) /* { dg-bogus "pointer wraparound" } */
17 return ptr + i;
18 else
19 return end;