Fix ICE in substring-handling building 502.gcc_r (PR 87562)
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstrict-overflow-18.c
blob8c8ddcf2b26ec6c8285a0cf6a8be814d6e7055d4
1 /* { dg-do compile } */
2 /* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */
4 /* Warn about an overflow when folding i > 0, p->a - p->b can be larger
5 than INT_MAX and thus i can wrap. */
7 struct c { unsigned int a; unsigned int b; };
8 extern void bar (struct c *);
9 int
10 foo (struct c *p)
12 int i;
13 int sum = 0;
15 for (i = 0; i < p->a - p->b; ++i)
17 /* See PR80511 for the XFAIL. */
18 if (i > 0) /* { dg-warning "signed overflow" "" { xfail *-*-* } } */
19 sum += 2;
20 bar (p);
22 return sum;