1 /* { dg-do compile } */
2 /* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */
3
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. */
6
7 struct c { unsigned int a; unsigned int b; };
8 extern void bar (struct c *);
9 int
10 foo (struct c *p)
11 {
12 int i;
13 int sum = 0;
14
15 for (i = 0; i < p->a - p->b; ++i)
16 {
17 /* See PR80511 for the XFAIL. */
18 if (i > 0) /* { dg-warning "signed overflow" "" { xfail *-*-* } } */
19 sum += 2;
20 bar (p);
21 }
22 return sum;
23 }