Fix warning with -Wsign-compare -Wsystem-headers
[official-gcc.git] / gcc / testsuite / gcc.dg / pr61240.c
blob6332918f01f649cdddff246a59b89c8ebca6c55e
1 /* PR c/61240 */
2 /* { dg-do compile } */
4 typedef __PTRDIFF_TYPE__ ptrdiff_t;
6 ptrdiff_t
7 foo (ptrdiff_t a[4])
9 int i[4];
10 int *p = i + 2;
11 static ptrdiff_t b = p - (p - 1); /* { dg-bogus "integer overflow in expression" } */
12 static ptrdiff_t c = (p - 1) - p; /* { dg-bogus "integer overflow in expression" } */
13 static ptrdiff_t d = (p - 2) - (p - 1);/* { dg-bogus "integer overflow in expression" } */
14 static ptrdiff_t e = (p - 1) - (p - 2);/* { dg-bogus "integer overflow in expression" } */
15 a[0] = p - (p - 1); /* { dg-bogus "integer overflow in expression" } */
16 a[1] = (p - 1) - p; /* { dg-bogus "integer overflow in expression" } */
17 a[2] = (p - 2) - (p - 1); /* { dg-bogus "integer overflow in expression" } */
18 a[3] = (p - 1) - (p - 2); /* { dg-bogus "integer overflow in expression" } */
19 return b + c + d + e;