1 // PR c++/50060
2 // { dg-do compile { target c++14 } }
3 
4 // sincos and lgamma_r aren't available in -std=c++14,
5 // only in -std=gnu++14.  Use __builtin_* in that case.
6 extern "C" void sincos (double, double *, double *);
7 extern "C" double frexp (double, int *);
8 extern "C" double modf (double, double *);
9 extern "C" double remquo (double, double, int *);
10 extern "C" double lgamma_r (double, int *);
11 
12 constexpr double
f0(double x)13 f0 (double x)
14 {
15   double y {};
16   double z {};
17   __builtin_sincos (x, &y, &z);
18   return y;
19 }
20 
21 constexpr double
f1(double x)22 f1 (double x)
23 {
24   double y {};
25   double z {};
26   __builtin_sincos (x, &y, &z);
27   return z;
28 }
29 
30 constexpr double
f2(double x)31 f2 (double x)
32 {
33   int y {};
34   return frexp (x, &y);
35 }
36 
37 constexpr int
f3(double x)38 f3 (double x)
39 {
40   int y {};
41   frexp (x, &y);
42   return y;
43 }
44 
45 constexpr double
f4(double x)46 f4 (double x)
47 {
48   double y {};
49   return modf (x, &y);
50 }
51 
52 constexpr double
f5(double x)53 f5 (double x)
54 {
55   double y {};
56   modf (x, &y);
57   return y;
58 }
59 
60 constexpr double
f6(double x,double y)61 f6 (double x, double y)
62 {
63   int z {};
64   return remquo (x, y, &z);
65 }
66 
67 constexpr int
f7(double x,double y)68 f7 (double x, double y)
69 {
70   int z {};
71   remquo (x, y, &z);
72   return z;
73 }
74 
75 constexpr double
f8(double x)76 f8 (double x)
77 {
78   int y {};
79   return __builtin_lgamma_r (x, &y);
80 }
81 
82 constexpr int
f9(double x)83 f9 (double x)
84 {
85   int y {};
86   __builtin_lgamma_r (x, &y);
87   return y;
88 }
89 
90 static_assert (f0 (0.0) == 0.0, "");
91 static_assert (f1 (0.0) == 1.0, "");
92 static_assert (f2 (6.5) == 0.8125, "");
93 static_assert (f3 (6.5) == 3, "");
94 static_assert (f4 (-7.25) == -0.25, "");
95 static_assert (f5 (-7.25) == -7.0, "");
96 static_assert (f6 (3.0, 2.0) == -1.0, "");
97 static_assert (f7 (3.0, 2.0) == 2, "");
98 static_assert (f8 (0.75) >= 0.20 && f8 (0.75) <= 0.21, "");
99 static_assert (f8 (0.75) >= 0.20 && f8 (0.75) <= 0.21, "");
100 static_assert (f9 (0.75) == 1, "");
101