PR tree-optimization/81303
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr79800.c
blob030e276698d105dd1ab1a7b775fb5fef48e02c59
1 /* PR 79800 - wrong snprintf result range with precision in a narrow
2 negative-positive range
3 { dg-do "run" { target c99_runtime } }
4 { dg-options "-O2 -Wall" } */
6 #define FMT "%.*a"
7 char fmt[] = FMT;
9 volatile double x = 1.23456789;
11 void f (int p)
13 if (p < -1 || 0 < p)
14 p = -1;
16 char d[30];
17 int n1 = __builtin_sprintf (d, "%.*a", p, x);
18 const char *s = n1 < 20 ? "< 20" : ">= 20";
20 if (__builtin_strcmp (s, ">= 20"))
21 __builtin_abort ();
24 volatile int i = -1;
26 int main ()
28 f (i);
30 return 0;