1 /* PR tree-optimization/83198 */
2 /* { dg-do compile { target __float128 } } */
3 /* { dg-options "-O2 -fprintf-return-value -Wno-format -fdump-tree-optimized" } */
4 /* { dg-add-options __float128 } */
5 
6 void bar (void);
7 void link_error (void);
8 
9 void
foo(char * x,double y)10 foo (char *x, double y)
11 {
12   /* The expected result should not be constant but rather that
13      of the %f directive with an unknown argument, i.e., at least
14      [3, 317] (but in reality [3, 322] when taking into account
15      that the decimal point can be up to MB_LEN_MAX bytes long).  */
16   int a = __builtin_sprintf (x, "%f", 1.0Q);
17   if (a < 3)
18     link_error ();
19   if (a > 13)
20     bar ();
21   if (a > 322)
22     link_error ();
23 }
24 
25 /* Verify we don't optimize return value to [3, 13].  */
26 /* { dg-final { scan-tree-dump-not "link_error \\(\\);" "optimized" } } */
27 /* { dg-final { scan-tree-dump "bar \\(\\);" "optimized" } } */
28