2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.dg / Wstrict-overflow-18.c
blob2767c44fbf24af2f5e3dbb2c833fe1d0bc5caf02
1 /* { dg-do compile } */
2 /* { dg-options "-fstrict-overflow -O2 -Wstrict-overflow" } */
4 /* Don't warn about an overflow when folding i > 0. The loop analysis
5 should determine that i does not wrap.
7 The test is really bogus, p->a - p->b can be larger than INT_MAX
8 and thus i can very well wrap. */
10 struct c { unsigned int a; unsigned int b; };
11 extern void bar (struct c *);
12 int
13 foo (struct c *p)
15 int i;
16 int sum = 0;
18 for (i = 0; i < p->a - p->b; ++i)
20 if (i > 0) /* { dg-bogus "warning" "" { xfail *-*-* } } */
21 sum += 2;
22 bar (p);
24 return sum;