PR tree-optimization/86274 - SEGFAULT when logging std::to_string(NAN)
[official-gcc.git] / gcc / testsuite / gcc.dg / tree-ssa / pr83198.c
blobcd0423990c74822c3d5b51031c8a36202bb1be29
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 } */
6 void bar (void);
7 void link_error (void);
9 void
10 foo (char *x, double y)
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 ();
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" } } */