PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr79327.c
blob7db875d5cdf86c3e6c55d0aa9c6f37fc854c42ae
1 /* PR tree-optimization/79327 - wrong code at -O2 and -fprintf-return-value
2 { dg-do run }
3 { dg-options "-O2 -Wall" } */
5 volatile int a, b = -1;
6 char buf[64];
8 #define FMT "%+03d%02d"
9 const char *volatile fmt = FMT;
11 int main ()
13 int c = a;
14 int d = b;
15 if (c >= -35791395 && c < 35791394 && d >= -1 && d < __INT_MAX__)
17 /* In the following the range of return values can be computed
18 by GCC. */
19 int n1 = __builtin_sprintf (buf, FMT, c + 1, d + 1);
20 if (n1 > 7)
21 __builtin_abort ();
23 /* Here GCC can't see the format string so the return value
24 must be computed by a libc call. */
25 int n2 = __builtin_sprintf (buf, fmt, c + 1, d + 1);
27 if (n1 != n2)
28 __builtin_abort ();
30 return 0;