1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <math.h>
10 
11 #include <math.h>
12 #include <type_traits>
13 #include <cassert>
14 
15 #include "test_macros.h"
16 #include "hexfloat.h"
17 #include "truncate_fp.h"
18 
19 // convertible to int/float/double/etc
20 template <class T, int N=0>
21 struct Value {
operator TValue22     operator T () { return T(N); }
23 };
24 
25 // See PR21083
26 // Ambiguous is a user-defined type that defines its own overloads of cmath
27 // functions. When the std overloads are candidates too (by using or adl),
28 // they should not interfere.
29 struct Ambiguous : std::true_type { // ADL
operator floatAmbiguous30     operator float () { return 0.f; }
operator doubleAmbiguous31     operator double () { return 0.; }
32 };
abs(Ambiguous)33 Ambiguous abs(Ambiguous){ return Ambiguous(); }
acos(Ambiguous)34 Ambiguous acos(Ambiguous){ return Ambiguous(); }
asin(Ambiguous)35 Ambiguous asin(Ambiguous){ return Ambiguous(); }
atan(Ambiguous)36 Ambiguous atan(Ambiguous){ return Ambiguous(); }
atan2(Ambiguous,Ambiguous)37 Ambiguous atan2(Ambiguous, Ambiguous){ return Ambiguous(); }
ceil(Ambiguous)38 Ambiguous ceil(Ambiguous){ return Ambiguous(); }
cos(Ambiguous)39 Ambiguous cos(Ambiguous){ return Ambiguous(); }
cosh(Ambiguous)40 Ambiguous cosh(Ambiguous){ return Ambiguous(); }
exp(Ambiguous)41 Ambiguous exp(Ambiguous){ return Ambiguous(); }
fabs(Ambiguous)42 Ambiguous fabs(Ambiguous){ return Ambiguous(); }
floor(Ambiguous)43 Ambiguous floor(Ambiguous){ return Ambiguous(); }
fmod(Ambiguous,Ambiguous)44 Ambiguous fmod(Ambiguous, Ambiguous){ return Ambiguous(); }
frexp(Ambiguous,int *)45 Ambiguous frexp(Ambiguous, int*){ return Ambiguous(); }
ldexp(Ambiguous,int)46 Ambiguous ldexp(Ambiguous, int){ return Ambiguous(); }
log(Ambiguous)47 Ambiguous log(Ambiguous){ return Ambiguous(); }
log10(Ambiguous)48 Ambiguous log10(Ambiguous){ return Ambiguous(); }
modf(Ambiguous,Ambiguous *)49 Ambiguous modf(Ambiguous, Ambiguous*){ return Ambiguous(); }
pow(Ambiguous,Ambiguous)50 Ambiguous pow(Ambiguous, Ambiguous){ return Ambiguous(); }
sin(Ambiguous)51 Ambiguous sin(Ambiguous){ return Ambiguous(); }
sinh(Ambiguous)52 Ambiguous sinh(Ambiguous){ return Ambiguous(); }
sqrt(Ambiguous)53 Ambiguous sqrt(Ambiguous){ return Ambiguous(); }
tan(Ambiguous)54 Ambiguous tan(Ambiguous){ return Ambiguous(); }
tanh(Ambiguous)55 Ambiguous tanh(Ambiguous){ return Ambiguous(); }
signbit(Ambiguous)56 Ambiguous signbit(Ambiguous){ return Ambiguous(); }
fpclassify(Ambiguous)57 Ambiguous fpclassify(Ambiguous){ return Ambiguous(); }
isfinite(Ambiguous)58 Ambiguous isfinite(Ambiguous){ return Ambiguous(); }
isnormal(Ambiguous)59 Ambiguous isnormal(Ambiguous){ return Ambiguous(); }
isgreater(Ambiguous,Ambiguous)60 Ambiguous isgreater(Ambiguous, Ambiguous){ return Ambiguous(); }
isgreaterequal(Ambiguous,Ambiguous)61 Ambiguous isgreaterequal(Ambiguous, Ambiguous){ return Ambiguous(); }
isless(Ambiguous,Ambiguous)62 Ambiguous isless(Ambiguous, Ambiguous){ return Ambiguous(); }
islessequal(Ambiguous,Ambiguous)63 Ambiguous islessequal(Ambiguous, Ambiguous){ return Ambiguous(); }
islessgreater(Ambiguous,Ambiguous)64 Ambiguous islessgreater(Ambiguous, Ambiguous){ return Ambiguous(); }
isunordered(Ambiguous,Ambiguous)65 Ambiguous isunordered(Ambiguous, Ambiguous){ return Ambiguous(); }
acosh(Ambiguous)66 Ambiguous acosh(Ambiguous){ return Ambiguous(); }
asinh(Ambiguous)67 Ambiguous asinh(Ambiguous){ return Ambiguous(); }
atanh(Ambiguous)68 Ambiguous atanh(Ambiguous){ return Ambiguous(); }
cbrt(Ambiguous)69 Ambiguous cbrt(Ambiguous){ return Ambiguous(); }
copysign(Ambiguous,Ambiguous)70 Ambiguous copysign(Ambiguous, Ambiguous){ return Ambiguous(); }
erf(Ambiguous)71 Ambiguous erf(Ambiguous){ return Ambiguous(); }
erfc(Ambiguous)72 Ambiguous erfc(Ambiguous){ return Ambiguous(); }
exp2(Ambiguous)73 Ambiguous exp2(Ambiguous){ return Ambiguous(); }
expm1(Ambiguous)74 Ambiguous expm1(Ambiguous){ return Ambiguous(); }
fdim(Ambiguous,Ambiguous)75 Ambiguous fdim(Ambiguous, Ambiguous){ return Ambiguous(); }
fma(Ambiguous,Ambiguous,Ambiguous)76 Ambiguous fma(Ambiguous, Ambiguous, Ambiguous){ return Ambiguous(); }
fmax(Ambiguous,Ambiguous)77 Ambiguous fmax(Ambiguous, Ambiguous){ return Ambiguous(); }
fmin(Ambiguous,Ambiguous)78 Ambiguous fmin(Ambiguous, Ambiguous){ return Ambiguous(); }
hypot(Ambiguous,Ambiguous)79 Ambiguous hypot(Ambiguous, Ambiguous){ return Ambiguous(); }
ilogb(Ambiguous)80 Ambiguous ilogb(Ambiguous){ return Ambiguous(); }
lgamma(Ambiguous)81 Ambiguous lgamma(Ambiguous){ return Ambiguous(); }
llrint(Ambiguous)82 Ambiguous llrint(Ambiguous){ return Ambiguous(); }
llround(Ambiguous)83 Ambiguous llround(Ambiguous){ return Ambiguous(); }
log1p(Ambiguous)84 Ambiguous log1p(Ambiguous){ return Ambiguous(); }
log2(Ambiguous)85 Ambiguous log2(Ambiguous){ return Ambiguous(); }
logb(Ambiguous)86 Ambiguous logb(Ambiguous){ return Ambiguous(); }
lrint(Ambiguous)87 Ambiguous lrint(Ambiguous){ return Ambiguous(); }
lround(Ambiguous)88 Ambiguous lround(Ambiguous){ return Ambiguous(); }
nearbyint(Ambiguous)89 Ambiguous nearbyint(Ambiguous){ return Ambiguous(); }
nextafter(Ambiguous,Ambiguous)90 Ambiguous nextafter(Ambiguous, Ambiguous){ return Ambiguous(); }
nexttoward(Ambiguous,Ambiguous)91 Ambiguous nexttoward(Ambiguous, Ambiguous){ return Ambiguous(); }
remainder(Ambiguous,Ambiguous)92 Ambiguous remainder(Ambiguous, Ambiguous){ return Ambiguous(); }
remquo(Ambiguous,Ambiguous,int *)93 Ambiguous remquo(Ambiguous, Ambiguous, int*){ return Ambiguous(); }
rint(Ambiguous)94 Ambiguous rint(Ambiguous){ return Ambiguous(); }
round(Ambiguous)95 Ambiguous round(Ambiguous){ return Ambiguous(); }
scalbln(Ambiguous,Ambiguous)96 Ambiguous scalbln(Ambiguous, Ambiguous){ return Ambiguous(); }
scalbn(Ambiguous,Ambiguous)97 Ambiguous scalbn(Ambiguous, Ambiguous){ return Ambiguous(); }
tgamma(Ambiguous)98 Ambiguous tgamma(Ambiguous){ return Ambiguous(); }
trunc(Ambiguous)99 Ambiguous trunc(Ambiguous){ return Ambiguous(); }
100 
101 template <class T, class = decltype(::abs(std::declval<T>()))>
102 std::true_type has_abs_imp(int);
103 template <class T>
104 std::false_type has_abs_imp(...);
105 
106 template <class T>
107 struct has_abs : decltype(has_abs_imp<T>(0)) {};
108 
test_abs()109 void test_abs()
110 {
111 #ifdef __clang__
112 #pragma clang diagnostic push
113 #pragma clang diagnostic ignored "-Wabsolute-value"
114 #endif
115   static_assert((std::is_same<decltype(abs((float)0)), float>::value), "");
116   static_assert((std::is_same<decltype(abs((double)0)), double>::value), "");
117   static_assert(
118       (std::is_same<decltype(abs((long double)0)), long double>::value), "");
119   static_assert((std::is_same<decltype(abs((int)0)), int>::value), "");
120   static_assert((std::is_same<decltype(abs((long)0)), long>::value), "");
121   static_assert((std::is_same<decltype(abs((long long)0)), long long>::value),
122                 "");
123   static_assert((std::is_same<decltype(abs((unsigned char)0)), int>::value),
124                 "");
125   static_assert((std::is_same<decltype(abs((unsigned short)0)), int>::value),
126                 "");
127 
128   static_assert((std::is_same<decltype(abs(Ambiguous())), Ambiguous>::value),
129                 "");
130 
131   static_assert(!has_abs<unsigned>::value, "");
132   static_assert(!has_abs<unsigned long>::value, "");
133   static_assert(!has_abs<unsigned long long>::value, "");
134 
135 #ifdef __clang__
136 #pragma clang diagnostic pop
137 #endif
138 
139   assert(abs(-1.) == 1);
140 }
141 
test_acos()142 void test_acos()
143 {
144     static_assert((std::is_same<decltype(acos((float)0)), float>::value), "");
145     static_assert((std::is_same<decltype(acos((bool)0)), double>::value), "");
146     static_assert((std::is_same<decltype(acos((unsigned short)0)), double>::value), "");
147     static_assert((std::is_same<decltype(acos((int)0)), double>::value), "");
148     static_assert((std::is_same<decltype(acos((unsigned int)0)), double>::value), "");
149     static_assert((std::is_same<decltype(acos((long)0)), double>::value), "");
150     static_assert((std::is_same<decltype(acos((unsigned long)0)), double>::value), "");
151     static_assert((std::is_same<decltype(acos((long long)0)), double>::value), "");
152     static_assert((std::is_same<decltype(acos((unsigned long long)0)), double>::value), "");
153     static_assert((std::is_same<decltype(acos((double)0)), double>::value), "");
154     static_assert((std::is_same<decltype(acos((long double)0)), long double>::value), "");
155     static_assert((std::is_same<decltype(acosf(0)), float>::value), "");
156     static_assert((std::is_same<decltype(acosl(0)), long double>::value), "");
157     static_assert((std::is_same<decltype(acos(Ambiguous())), Ambiguous>::value), "");
158     assert(acos(1) == 0);
159 }
160 
test_asin()161 void test_asin()
162 {
163     static_assert((std::is_same<decltype(asin((float)0)), float>::value), "");
164     static_assert((std::is_same<decltype(asin((bool)0)), double>::value), "");
165     static_assert((std::is_same<decltype(asin((unsigned short)0)), double>::value), "");
166     static_assert((std::is_same<decltype(asin((int)0)), double>::value), "");
167     static_assert((std::is_same<decltype(asin((unsigned int)0)), double>::value), "");
168     static_assert((std::is_same<decltype(asin((long)0)), double>::value), "");
169     static_assert((std::is_same<decltype(asin((unsigned long)0)), double>::value), "");
170     static_assert((std::is_same<decltype(asin((long long)0)), double>::value), "");
171     static_assert((std::is_same<decltype(asin((unsigned long long)0)), double>::value), "");
172     static_assert((std::is_same<decltype(asin((double)0)), double>::value), "");
173     static_assert((std::is_same<decltype(asin((long double)0)), long double>::value), "");
174     static_assert((std::is_same<decltype(asinf(0)), float>::value), "");
175     static_assert((std::is_same<decltype(asinl(0)), long double>::value), "");
176     static_assert((std::is_same<decltype(asin(Ambiguous())), Ambiguous>::value), "");
177     assert(asin(0) == 0);
178 }
179 
test_atan()180 void test_atan()
181 {
182     static_assert((std::is_same<decltype(atan((float)0)), float>::value), "");
183     static_assert((std::is_same<decltype(atan((bool)0)), double>::value), "");
184     static_assert((std::is_same<decltype(atan((unsigned short)0)), double>::value), "");
185     static_assert((std::is_same<decltype(atan((int)0)), double>::value), "");
186     static_assert((std::is_same<decltype(atan((unsigned int)0)), double>::value), "");
187     static_assert((std::is_same<decltype(atan((long)0)), double>::value), "");
188     static_assert((std::is_same<decltype(atan((unsigned long)0)), double>::value), "");
189     static_assert((std::is_same<decltype(atan((long long)0)), double>::value), "");
190     static_assert((std::is_same<decltype(atan((unsigned long long)0)), double>::value), "");
191     static_assert((std::is_same<decltype(atan((double)0)), double>::value), "");
192     static_assert((std::is_same<decltype(atan((long double)0)), long double>::value), "");
193     static_assert((std::is_same<decltype(atanf(0)), float>::value), "");
194     static_assert((std::is_same<decltype(atanl(0)), long double>::value), "");
195     static_assert((std::is_same<decltype(atan(Ambiguous())), Ambiguous>::value), "");
196     assert(atan(0) == 0);
197 }
198 
test_atan2()199 void test_atan2()
200 {
201     static_assert((std::is_same<decltype(atan2((float)0, (float)0)), float>::value), "");
202     static_assert((std::is_same<decltype(atan2((bool)0, (float)0)), double>::value), "");
203     static_assert((std::is_same<decltype(atan2((unsigned short)0, (double)0)), double>::value), "");
204     static_assert((std::is_same<decltype(atan2((int)0, (long double)0)), long double>::value), "");
205     static_assert((std::is_same<decltype(atan2((float)0, (unsigned int)0)), double>::value), "");
206     static_assert((std::is_same<decltype(atan2((double)0, (long)0)), double>::value), "");
207     static_assert((std::is_same<decltype(atan2((long double)0, (unsigned long)0)), long double>::value), "");
208     static_assert((std::is_same<decltype(atan2((int)0, (long long)0)), double>::value), "");
209     static_assert((std::is_same<decltype(atan2((int)0, (unsigned long long)0)), double>::value), "");
210     static_assert((std::is_same<decltype(atan2((double)0, (double)0)), double>::value), "");
211     static_assert((std::is_same<decltype(atan2((long double)0, (long double)0)), long double>::value), "");
212     static_assert((std::is_same<decltype(atan2((float)0, (double)0)), double>::value), "");
213     static_assert((std::is_same<decltype(atan2((float)0, (long double)0)), long double>::value), "");
214     static_assert((std::is_same<decltype(atan2((double)0, (long double)0)), long double>::value), "");
215     static_assert((std::is_same<decltype(atan2f(0,0)), float>::value), "");
216     static_assert((std::is_same<decltype(atan2l(0,0)), long double>::value), "");
217     static_assert((std::is_same<decltype(atan2((int)0, (int)0)), double>::value), "");
218     static_assert((std::is_same<decltype(atan2(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
219     assert(atan2(0,1) == 0);
220 }
221 
test_ceil()222 void test_ceil()
223 {
224     static_assert((std::is_same<decltype(ceil((float)0)), float>::value), "");
225     static_assert((std::is_same<decltype(ceil((bool)0)), double>::value), "");
226     static_assert((std::is_same<decltype(ceil((unsigned short)0)), double>::value), "");
227     static_assert((std::is_same<decltype(ceil((int)0)), double>::value), "");
228     static_assert((std::is_same<decltype(ceil((unsigned int)0)), double>::value), "");
229     static_assert((std::is_same<decltype(ceil((long)0)), double>::value), "");
230     static_assert((std::is_same<decltype(ceil((unsigned long)0)), double>::value), "");
231     static_assert((std::is_same<decltype(ceil((long long)0)), double>::value), "");
232     static_assert((std::is_same<decltype(ceil((unsigned long long)0)), double>::value), "");
233     static_assert((std::is_same<decltype(ceil((double)0)), double>::value), "");
234     static_assert((std::is_same<decltype(ceil((long double)0)), long double>::value), "");
235     static_assert((std::is_same<decltype(ceilf(0)), float>::value), "");
236     static_assert((std::is_same<decltype(ceill(0)), long double>::value), "");
237     static_assert((std::is_same<decltype(ceil(Ambiguous())), Ambiguous>::value), "");
238     assert(ceil(0) == 0);
239 }
240 
test_cos()241 void test_cos()
242 {
243     static_assert((std::is_same<decltype(cos((float)0)), float>::value), "");
244     static_assert((std::is_same<decltype(cos((bool)0)), double>::value), "");
245     static_assert((std::is_same<decltype(cos((unsigned short)0)), double>::value), "");
246     static_assert((std::is_same<decltype(cos((int)0)), double>::value), "");
247     static_assert((std::is_same<decltype(cos((unsigned int)0)), double>::value), "");
248     static_assert((std::is_same<decltype(cos((long)0)), double>::value), "");
249     static_assert((std::is_same<decltype(cos((unsigned long)0)), double>::value), "");
250     static_assert((std::is_same<decltype(cos((long long)0)), double>::value), "");
251     static_assert((std::is_same<decltype(cos((unsigned long long)0)), double>::value), "");
252     static_assert((std::is_same<decltype(cos((double)0)), double>::value), "");
253     static_assert((std::is_same<decltype(cos((long double)0)), long double>::value), "");
254     static_assert((std::is_same<decltype(cosf(0)), float>::value), "");
255     static_assert((std::is_same<decltype(cosl(0)), long double>::value), "");
256     static_assert((std::is_same<decltype(cos(Ambiguous())), Ambiguous>::value), "");
257     assert(cos(0) == 1);
258 }
259 
test_cosh()260 void test_cosh()
261 {
262     static_assert((std::is_same<decltype(cosh((float)0)), float>::value), "");
263     static_assert((std::is_same<decltype(cosh((bool)0)), double>::value), "");
264     static_assert((std::is_same<decltype(cosh((unsigned short)0)), double>::value), "");
265     static_assert((std::is_same<decltype(cosh((int)0)), double>::value), "");
266     static_assert((std::is_same<decltype(cosh((unsigned int)0)), double>::value), "");
267     static_assert((std::is_same<decltype(cosh((long)0)), double>::value), "");
268     static_assert((std::is_same<decltype(cosh((unsigned long)0)), double>::value), "");
269     static_assert((std::is_same<decltype(cosh((long long)0)), double>::value), "");
270     static_assert((std::is_same<decltype(cosh((unsigned long long)0)), double>::value), "");
271     static_assert((std::is_same<decltype(cosh((double)0)), double>::value), "");
272     static_assert((std::is_same<decltype(cosh((long double)0)), long double>::value), "");
273     static_assert((std::is_same<decltype(coshf(0)), float>::value), "");
274     static_assert((std::is_same<decltype(coshl(0)), long double>::value), "");
275     static_assert((std::is_same<decltype(cosh(Ambiguous())), Ambiguous>::value), "");
276     assert(cosh(0) == 1);
277 }
278 
test_exp()279 void test_exp()
280 {
281     static_assert((std::is_same<decltype(exp((float)0)), float>::value), "");
282     static_assert((std::is_same<decltype(exp((bool)0)), double>::value), "");
283     static_assert((std::is_same<decltype(exp((unsigned short)0)), double>::value), "");
284     static_assert((std::is_same<decltype(exp((int)0)), double>::value), "");
285     static_assert((std::is_same<decltype(exp((unsigned int)0)), double>::value), "");
286     static_assert((std::is_same<decltype(exp((long)0)), double>::value), "");
287     static_assert((std::is_same<decltype(exp((unsigned long)0)), double>::value), "");
288     static_assert((std::is_same<decltype(exp((long long)0)), double>::value), "");
289     static_assert((std::is_same<decltype(exp((unsigned long long)0)), double>::value), "");
290     static_assert((std::is_same<decltype(exp((double)0)), double>::value), "");
291     static_assert((std::is_same<decltype(exp((long double)0)), long double>::value), "");
292     static_assert((std::is_same<decltype(expf(0)), float>::value), "");
293     static_assert((std::is_same<decltype(expl(0)), long double>::value), "");
294     static_assert((std::is_same<decltype(exp(Ambiguous())), Ambiguous>::value), "");
295     assert(exp(0) == 1);
296 }
297 
test_fabs()298 void test_fabs()
299 {
300     static_assert((std::is_same<decltype(fabs((float)0)), float>::value), "");
301     static_assert((std::is_same<decltype(fabs((bool)0)), double>::value), "");
302     static_assert((std::is_same<decltype(fabs((unsigned short)0)), double>::value), "");
303     static_assert((std::is_same<decltype(fabs((int)0)), double>::value), "");
304     static_assert((std::is_same<decltype(fabs((unsigned int)0)), double>::value), "");
305     static_assert((std::is_same<decltype(fabs((long)0)), double>::value), "");
306     static_assert((std::is_same<decltype(fabs((unsigned long)0)), double>::value), "");
307     static_assert((std::is_same<decltype(fabs((long long)0)), double>::value), "");
308     static_assert((std::is_same<decltype(fabs((unsigned long long)0)), double>::value), "");
309     static_assert((std::is_same<decltype(fabs((double)0)), double>::value), "");
310     static_assert((std::is_same<decltype(fabs((long double)0)), long double>::value), "");
311     static_assert((std::is_same<decltype(fabsf(0.0f)), float>::value), "");
312     static_assert((std::is_same<decltype(fabsl(0.0L)), long double>::value), "");
313     static_assert((std::is_same<decltype(fabs(Ambiguous())), Ambiguous>::value), "");
314     assert(fabs(-1) == 1);
315 }
316 
test_floor()317 void test_floor()
318 {
319     static_assert((std::is_same<decltype(floor((float)0)), float>::value), "");
320     static_assert((std::is_same<decltype(floor((bool)0)), double>::value), "");
321     static_assert((std::is_same<decltype(floor((unsigned short)0)), double>::value), "");
322     static_assert((std::is_same<decltype(floor((int)0)), double>::value), "");
323     static_assert((std::is_same<decltype(floor((unsigned int)0)), double>::value), "");
324     static_assert((std::is_same<decltype(floor((long)0)), double>::value), "");
325     static_assert((std::is_same<decltype(floor((unsigned long)0)), double>::value), "");
326     static_assert((std::is_same<decltype(floor((long long)0)), double>::value), "");
327     static_assert((std::is_same<decltype(floor((unsigned long long)0)), double>::value), "");
328     static_assert((std::is_same<decltype(floor((double)0)), double>::value), "");
329     static_assert((std::is_same<decltype(floor((long double)0)), long double>::value), "");
330     static_assert((std::is_same<decltype(floorf(0)), float>::value), "");
331     static_assert((std::is_same<decltype(floorl(0)), long double>::value), "");
332     static_assert((std::is_same<decltype(floor(Ambiguous())), Ambiguous>::value), "");
333     assert(floor(1) == 1);
334 }
335 
test_fmod()336 void test_fmod()
337 {
338     static_assert((std::is_same<decltype(fmod((float)0, (float)0)), float>::value), "");
339     static_assert((std::is_same<decltype(fmod((bool)0, (float)0)), double>::value), "");
340     static_assert((std::is_same<decltype(fmod((unsigned short)0, (double)0)), double>::value), "");
341     static_assert((std::is_same<decltype(fmod((int)0, (long double)0)), long double>::value), "");
342     static_assert((std::is_same<decltype(fmod((float)0, (unsigned int)0)), double>::value), "");
343     static_assert((std::is_same<decltype(fmod((double)0, (long)0)), double>::value), "");
344     static_assert((std::is_same<decltype(fmod((long double)0, (unsigned long)0)), long double>::value), "");
345     static_assert((std::is_same<decltype(fmod((int)0, (long long)0)), double>::value), "");
346     static_assert((std::is_same<decltype(fmod((int)0, (unsigned long long)0)), double>::value), "");
347     static_assert((std::is_same<decltype(fmod((double)0, (double)0)), double>::value), "");
348     static_assert((std::is_same<decltype(fmod((long double)0, (long double)0)), long double>::value), "");
349     static_assert((std::is_same<decltype(fmod((float)0, (double)0)), double>::value), "");
350     static_assert((std::is_same<decltype(fmod((float)0, (long double)0)), long double>::value), "");
351     static_assert((std::is_same<decltype(fmod((double)0, (long double)0)), long double>::value), "");
352     static_assert((std::is_same<decltype(fmodf(0,0)), float>::value), "");
353     static_assert((std::is_same<decltype(fmodl(0,0)), long double>::value), "");
354     static_assert((std::is_same<decltype(fmod((int)0, (int)0)), double>::value), "");
355     static_assert((std::is_same<decltype(fmod(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
356     assert(fmod(1.5,1) == .5);
357 }
358 
test_frexp()359 void test_frexp()
360 {
361     int ip;
362     static_assert((std::is_same<decltype(frexp((float)0, &ip)), float>::value), "");
363     static_assert((std::is_same<decltype(frexp((bool)0, &ip)), double>::value), "");
364     static_assert((std::is_same<decltype(frexp((unsigned short)0, &ip)), double>::value), "");
365     static_assert((std::is_same<decltype(frexp((int)0, &ip)), double>::value), "");
366     static_assert((std::is_same<decltype(frexp((unsigned int)0, &ip)), double>::value), "");
367     static_assert((std::is_same<decltype(frexp((long)0, &ip)), double>::value), "");
368     static_assert((std::is_same<decltype(frexp((unsigned long)0, &ip)), double>::value), "");
369     static_assert((std::is_same<decltype(frexp((long long)0, &ip)), double>::value), "");
370     static_assert((std::is_same<decltype(frexp((unsigned long long)0, &ip)), double>::value), "");
371     static_assert((std::is_same<decltype(frexp((double)0, &ip)), double>::value), "");
372     static_assert((std::is_same<decltype(frexp((long double)0, &ip)), long double>::value), "");
373     static_assert((std::is_same<decltype(frexpf(0, &ip)), float>::value), "");
374     static_assert((std::is_same<decltype(frexpl(0, &ip)), long double>::value), "");
375     static_assert((std::is_same<decltype(frexp(Ambiguous(), &ip)), Ambiguous>::value), "");
376     assert(frexp(0, &ip) == 0);
377 }
378 
test_ldexp()379 void test_ldexp()
380 {
381     int ip = 1;
382     static_assert((std::is_same<decltype(ldexp((float)0, ip)), float>::value), "");
383     static_assert((std::is_same<decltype(ldexp((bool)0, ip)), double>::value), "");
384     static_assert((std::is_same<decltype(ldexp((unsigned short)0, ip)), double>::value), "");
385     static_assert((std::is_same<decltype(ldexp((int)0, ip)), double>::value), "");
386     static_assert((std::is_same<decltype(ldexp((unsigned int)0, ip)), double>::value), "");
387     static_assert((std::is_same<decltype(ldexp((long)0, ip)), double>::value), "");
388     static_assert((std::is_same<decltype(ldexp((unsigned long)0, ip)), double>::value), "");
389     static_assert((std::is_same<decltype(ldexp((long long)0, ip)), double>::value), "");
390     static_assert((std::is_same<decltype(ldexp((unsigned long long)0, ip)), double>::value), "");
391     static_assert((std::is_same<decltype(ldexp((double)0, ip)), double>::value), "");
392     static_assert((std::is_same<decltype(ldexp((long double)0, ip)), long double>::value), "");
393     static_assert((std::is_same<decltype(ldexpf(0, ip)), float>::value), "");
394     static_assert((std::is_same<decltype(ldexpl(0, ip)), long double>::value), "");
395     static_assert((std::is_same<decltype(ldexp(Ambiguous(), ip)), Ambiguous>::value), "");
396     assert(ldexp(1, ip) == 2);
397 }
398 
test_log()399 void test_log()
400 {
401     static_assert((std::is_same<decltype(log((float)0)), float>::value), "");
402     static_assert((std::is_same<decltype(log((bool)0)), double>::value), "");
403     static_assert((std::is_same<decltype(log((unsigned short)0)), double>::value), "");
404     static_assert((std::is_same<decltype(log((int)0)), double>::value), "");
405     static_assert((std::is_same<decltype(log((unsigned int)0)), double>::value), "");
406     static_assert((std::is_same<decltype(log((long)0)), double>::value), "");
407     static_assert((std::is_same<decltype(log((unsigned long)0)), double>::value), "");
408     static_assert((std::is_same<decltype(log((long long)0)), double>::value), "");
409     static_assert((std::is_same<decltype(log((unsigned long long)0)), double>::value), "");
410     static_assert((std::is_same<decltype(log((double)0)), double>::value), "");
411     static_assert((std::is_same<decltype(log((long double)0)), long double>::value), "");
412     static_assert((std::is_same<decltype(logf(0)), float>::value), "");
413     static_assert((std::is_same<decltype(logl(0)), long double>::value), "");
414     static_assert((std::is_same<decltype(log(Ambiguous())), Ambiguous>::value), "");
415     assert(log(1) == 0);
416 }
417 
test_log10()418 void test_log10()
419 {
420     static_assert((std::is_same<decltype(log10((float)0)), float>::value), "");
421     static_assert((std::is_same<decltype(log10((bool)0)), double>::value), "");
422     static_assert((std::is_same<decltype(log10((unsigned short)0)), double>::value), "");
423     static_assert((std::is_same<decltype(log10((int)0)), double>::value), "");
424     static_assert((std::is_same<decltype(log10((unsigned int)0)), double>::value), "");
425     static_assert((std::is_same<decltype(log10((long)0)), double>::value), "");
426     static_assert((std::is_same<decltype(log10((unsigned long)0)), double>::value), "");
427     static_assert((std::is_same<decltype(log10((long long)0)), double>::value), "");
428     static_assert((std::is_same<decltype(log10((unsigned long long)0)), double>::value), "");
429     static_assert((std::is_same<decltype(log10((double)0)), double>::value), "");
430     static_assert((std::is_same<decltype(log10((long double)0)), long double>::value), "");
431     static_assert((std::is_same<decltype(log10f(0)), float>::value), "");
432     static_assert((std::is_same<decltype(log10l(0)), long double>::value), "");
433     static_assert((std::is_same<decltype(log10(Ambiguous())), Ambiguous>::value), "");
434     assert(log10(1) == 0);
435 }
436 
test_modf()437 void test_modf()
438 {
439     static_assert((std::is_same<decltype(modf((float)0, (float*)0)), float>::value), "");
440     static_assert((std::is_same<decltype(modf((double)0, (double*)0)), double>::value), "");
441     static_assert((std::is_same<decltype(modf((long double)0, (long double*)0)), long double>::value), "");
442     static_assert((std::is_same<decltype(modff(0, (float*)0)), float>::value), "");
443     static_assert((std::is_same<decltype(modfl(0, (long double*)0)), long double>::value), "");
444     static_assert((std::is_same<decltype(modf(Ambiguous(), (Ambiguous*)0)), Ambiguous>::value), "");
445     double i;
446     assert(modf(1., &i) == 0);
447 }
448 
test_pow()449 void test_pow()
450 {
451     static_assert((std::is_same<decltype(pow((float)0, (float)0)), float>::value), "");
452     static_assert((std::is_same<decltype(pow((bool)0, (float)0)), double>::value), "");
453     static_assert((std::is_same<decltype(pow((unsigned short)0, (double)0)), double>::value), "");
454     static_assert((std::is_same<decltype(pow((int)0, (long double)0)), long double>::value), "");
455     static_assert((std::is_same<decltype(pow((float)0, (unsigned int)0)), double>::value), "");
456     static_assert((std::is_same<decltype(pow((double)0, (long)0)), double>::value), "");
457     static_assert((std::is_same<decltype(pow((long double)0, (unsigned long)0)), long double>::value), "");
458     static_assert((std::is_same<decltype(pow((int)0, (long long)0)), double>::value), "");
459     static_assert((std::is_same<decltype(pow((int)0, (unsigned long long)0)), double>::value), "");
460     static_assert((std::is_same<decltype(pow((double)0, (double)0)), double>::value), "");
461     static_assert((std::is_same<decltype(pow((long double)0, (long double)0)), long double>::value), "");
462     static_assert((std::is_same<decltype(pow((float)0, (double)0)), double>::value), "");
463     static_assert((std::is_same<decltype(pow((float)0, (long double)0)), long double>::value), "");
464     static_assert((std::is_same<decltype(pow((double)0, (long double)0)), long double>::value), "");
465     static_assert((std::is_same<decltype(powf(0,0)), float>::value), "");
466     static_assert((std::is_same<decltype(powl(0,0)), long double>::value), "");
467     static_assert((std::is_same<decltype(pow((int)0, (int)0)), double>::value), "");
468 //     static_assert((std::is_same<decltype(pow(Value<int>(), (int)0)), double>::value), "");
469 //     static_assert((std::is_same<decltype(pow(Value<long double>(), (float)0)), long double>::value), "");
470 //     static_assert((std::is_same<decltype(pow((float) 0, Value<float>())), float>::value), "");
471     static_assert((std::is_same<decltype(pow(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
472     assert(pow(1,1) == 1);
473 //     assert(pow(Value<int,1>(), Value<float,1>())  == 1);
474 //     assert(pow(1.0f, Value<double,1>()) == 1);
475 //     assert(pow(1.0, Value<int,1>()) == 1);
476 //     assert(pow(Value<long double,1>(), 1LL) == 1);
477 }
478 
test_sin()479 void test_sin()
480 {
481     static_assert((std::is_same<decltype(sin((float)0)), float>::value), "");
482     static_assert((std::is_same<decltype(sin((bool)0)), double>::value), "");
483     static_assert((std::is_same<decltype(sin((unsigned short)0)), double>::value), "");
484     static_assert((std::is_same<decltype(sin((int)0)), double>::value), "");
485     static_assert((std::is_same<decltype(sin((unsigned int)0)), double>::value), "");
486     static_assert((std::is_same<decltype(sin((long)0)), double>::value), "");
487     static_assert((std::is_same<decltype(sin((unsigned long)0)), double>::value), "");
488     static_assert((std::is_same<decltype(sin((long long)0)), double>::value), "");
489     static_assert((std::is_same<decltype(sin((unsigned long long)0)), double>::value), "");
490     static_assert((std::is_same<decltype(sin((double)0)), double>::value), "");
491     static_assert((std::is_same<decltype(sin((long double)0)), long double>::value), "");
492     static_assert((std::is_same<decltype(sinf(0)), float>::value), "");
493     static_assert((std::is_same<decltype(sinl(0)), long double>::value), "");
494     static_assert((std::is_same<decltype(sin(Ambiguous())), Ambiguous>::value), "");
495     assert(sin(0) == 0);
496 }
497 
test_sinh()498 void test_sinh()
499 {
500     static_assert((std::is_same<decltype(sinh((float)0)), float>::value), "");
501     static_assert((std::is_same<decltype(sinh((bool)0)), double>::value), "");
502     static_assert((std::is_same<decltype(sinh((unsigned short)0)), double>::value), "");
503     static_assert((std::is_same<decltype(sinh((int)0)), double>::value), "");
504     static_assert((std::is_same<decltype(sinh((unsigned int)0)), double>::value), "");
505     static_assert((std::is_same<decltype(sinh((long)0)), double>::value), "");
506     static_assert((std::is_same<decltype(sinh((unsigned long)0)), double>::value), "");
507     static_assert((std::is_same<decltype(sinh((long long)0)), double>::value), "");
508     static_assert((std::is_same<decltype(sinh((unsigned long long)0)), double>::value), "");
509     static_assert((std::is_same<decltype(sinh((double)0)), double>::value), "");
510     static_assert((std::is_same<decltype(sinh((long double)0)), long double>::value), "");
511     static_assert((std::is_same<decltype(sinhf(0)), float>::value), "");
512     static_assert((std::is_same<decltype(sinhl(0)), long double>::value), "");
513     static_assert((std::is_same<decltype(sinh(Ambiguous())), Ambiguous>::value), "");
514     assert(sinh(0) == 0);
515 }
516 
test_sqrt()517 void test_sqrt()
518 {
519     static_assert((std::is_same<decltype(sqrt((float)0)), float>::value), "");
520     static_assert((std::is_same<decltype(sqrt((bool)0)), double>::value), "");
521     static_assert((std::is_same<decltype(sqrt((unsigned short)0)), double>::value), "");
522     static_assert((std::is_same<decltype(sqrt((int)0)), double>::value), "");
523     static_assert((std::is_same<decltype(sqrt((unsigned int)0)), double>::value), "");
524     static_assert((std::is_same<decltype(sqrt((long)0)), double>::value), "");
525     static_assert((std::is_same<decltype(sqrt((unsigned long)0)), double>::value), "");
526     static_assert((std::is_same<decltype(sqrt((long long)0)), double>::value), "");
527     static_assert((std::is_same<decltype(sqrt((unsigned long long)0)), double>::value), "");
528     static_assert((std::is_same<decltype(sqrt((double)0)), double>::value), "");
529     static_assert((std::is_same<decltype(sqrt((long double)0)), long double>::value), "");
530     static_assert((std::is_same<decltype(sqrtf(0)), float>::value), "");
531     static_assert((std::is_same<decltype(sqrtl(0)), long double>::value), "");
532     static_assert((std::is_same<decltype(sqrt(Ambiguous())), Ambiguous>::value), "");
533     assert(sqrt(4) == 2);
534 }
535 
test_tan()536 void test_tan()
537 {
538     static_assert((std::is_same<decltype(tan((float)0)), float>::value), "");
539     static_assert((std::is_same<decltype(tan((bool)0)), double>::value), "");
540     static_assert((std::is_same<decltype(tan((unsigned short)0)), double>::value), "");
541     static_assert((std::is_same<decltype(tan((int)0)), double>::value), "");
542     static_assert((std::is_same<decltype(tan((unsigned int)0)), double>::value), "");
543     static_assert((std::is_same<decltype(tan((long)0)), double>::value), "");
544     static_assert((std::is_same<decltype(tan((unsigned long)0)), double>::value), "");
545     static_assert((std::is_same<decltype(tan((long long)0)), double>::value), "");
546     static_assert((std::is_same<decltype(tan((unsigned long long)0)), double>::value), "");
547     static_assert((std::is_same<decltype(tan((double)0)), double>::value), "");
548     static_assert((std::is_same<decltype(tan((long double)0)), long double>::value), "");
549     static_assert((std::is_same<decltype(tanf(0)), float>::value), "");
550     static_assert((std::is_same<decltype(tanl(0)), long double>::value), "");
551     static_assert((std::is_same<decltype(tan(Ambiguous())), Ambiguous>::value), "");
552     assert(tan(0) == 0);
553 }
554 
test_tanh()555 void test_tanh()
556 {
557     static_assert((std::is_same<decltype(tanh((float)0)), float>::value), "");
558     static_assert((std::is_same<decltype(tanh((bool)0)), double>::value), "");
559     static_assert((std::is_same<decltype(tanh((unsigned short)0)), double>::value), "");
560     static_assert((std::is_same<decltype(tanh((int)0)), double>::value), "");
561     static_assert((std::is_same<decltype(tanh((unsigned int)0)), double>::value), "");
562     static_assert((std::is_same<decltype(tanh((long)0)), double>::value), "");
563     static_assert((std::is_same<decltype(tanh((unsigned long)0)), double>::value), "");
564     static_assert((std::is_same<decltype(tanh((long long)0)), double>::value), "");
565     static_assert((std::is_same<decltype(tanh((unsigned long long)0)), double>::value), "");
566     static_assert((std::is_same<decltype(tanh((double)0)), double>::value), "");
567     static_assert((std::is_same<decltype(tanh((long double)0)), long double>::value), "");
568     static_assert((std::is_same<decltype(tanhf(0)), float>::value), "");
569     static_assert((std::is_same<decltype(tanhl(0)), long double>::value), "");
570     static_assert((std::is_same<decltype(tanh(Ambiguous())), Ambiguous>::value), "");
571     assert(tanh(0) == 0);
572 }
573 
test_signbit()574 void test_signbit()
575 {
576 #ifdef signbit
577 #error signbit defined
578 #endif
579     static_assert((std::is_same<decltype(signbit((float)0)), bool>::value), "");
580     static_assert((std::is_same<decltype(signbit((double)0)), bool>::value), "");
581     static_assert((std::is_same<decltype(signbit(0)), bool>::value), "");
582     static_assert((std::is_same<decltype(signbit((long double)0)), bool>::value), "");
583     static_assert((std::is_same<decltype(signbit(Ambiguous())), Ambiguous>::value), "");
584     assert(signbit(-1.0) == true);
585 }
586 
test_fpclassify()587 void test_fpclassify()
588 {
589 #ifdef fpclassify
590 #error fpclassify defined
591 #endif
592     static_assert((std::is_same<decltype(fpclassify((float)0)), int>::value), "");
593     static_assert((std::is_same<decltype(fpclassify((double)0)), int>::value), "");
594     static_assert((std::is_same<decltype(fpclassify(0)), int>::value), "");
595     static_assert((std::is_same<decltype(fpclassify((long double)0)), int>::value), "");
596     static_assert((std::is_same<decltype(fpclassify(Ambiguous())), Ambiguous>::value), "");
597     assert(fpclassify(-1.0) == FP_NORMAL);
598 }
599 
test_isfinite()600 void test_isfinite()
601 {
602 #ifdef isfinite
603 #error isfinite defined
604 #endif
605     static_assert((std::is_same<decltype(isfinite((float)0)), bool>::value), "");
606     static_assert((std::is_same<decltype(isfinite((double)0)), bool>::value), "");
607     static_assert((std::is_same<decltype(isfinite(0)), bool>::value), "");
608     static_assert((std::is_same<decltype(isfinite((long double)0)), bool>::value), "");
609     static_assert((std::is_same<decltype(isfinite(Ambiguous())), Ambiguous>::value), "");
610     assert(isfinite(-1.0) == true);
611 }
612 
test_isnormal()613 void test_isnormal()
614 {
615 #ifdef isnormal
616 #error isnormal defined
617 #endif
618     static_assert((std::is_same<decltype(isnormal((float)0)), bool>::value), "");
619     static_assert((std::is_same<decltype(isnormal((double)0)), bool>::value), "");
620     static_assert((std::is_same<decltype(isnormal(0)), bool>::value), "");
621     static_assert((std::is_same<decltype(isnormal((long double)0)), bool>::value), "");
622     static_assert((std::is_same<decltype(isnormal(Ambiguous())), Ambiguous>::value), "");
623     assert(isnormal(-1.0) == true);
624 }
625 
test_isgreater()626 void test_isgreater()
627 {
628 #ifdef isgreater
629 #error isgreater defined
630 #endif
631     static_assert((std::is_same<decltype(isgreater((float)0, (float)0)), bool>::value), "");
632     static_assert((std::is_same<decltype(isgreater((float)0, (double)0)), bool>::value), "");
633     static_assert((std::is_same<decltype(isgreater((float)0, (long double)0)), bool>::value), "");
634     static_assert((std::is_same<decltype(isgreater((double)0, (float)0)), bool>::value), "");
635     static_assert((std::is_same<decltype(isgreater((double)0, (double)0)), bool>::value), "");
636     static_assert((std::is_same<decltype(isgreater(0, (double)0)), bool>::value), "");
637     static_assert((std::is_same<decltype(isgreater((double)0, (long double)0)), bool>::value), "");
638     static_assert((std::is_same<decltype(isgreater((long double)0, (float)0)), bool>::value), "");
639     static_assert((std::is_same<decltype(isgreater((long double)0, (double)0)), bool>::value), "");
640     static_assert((std::is_same<decltype(isgreater((long double)0, (long double)0)), bool>::value), "");
641     static_assert((std::is_same<decltype(isgreater(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
642     assert(isgreater(-1.0, 0.F) == false);
643 }
644 
test_isgreaterequal()645 void test_isgreaterequal()
646 {
647 #ifdef isgreaterequal
648 #error isgreaterequal defined
649 #endif
650     static_assert((std::is_same<decltype(isgreaterequal((float)0, (float)0)), bool>::value), "");
651     static_assert((std::is_same<decltype(isgreaterequal((float)0, (double)0)), bool>::value), "");
652     static_assert((std::is_same<decltype(isgreaterequal((float)0, (long double)0)), bool>::value), "");
653     static_assert((std::is_same<decltype(isgreaterequal((double)0, (float)0)), bool>::value), "");
654     static_assert((std::is_same<decltype(isgreaterequal((double)0, (double)0)), bool>::value), "");
655     static_assert((std::is_same<decltype(isgreaterequal(0, (double)0)), bool>::value), "");
656     static_assert((std::is_same<decltype(isgreaterequal((double)0, (long double)0)), bool>::value), "");
657     static_assert((std::is_same<decltype(isgreaterequal((long double)0, (float)0)), bool>::value), "");
658     static_assert((std::is_same<decltype(isgreaterequal((long double)0, (double)0)), bool>::value), "");
659     static_assert((std::is_same<decltype(isgreaterequal((long double)0, (long double)0)), bool>::value), "");
660     static_assert((std::is_same<decltype(isgreaterequal(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
661     assert(isgreaterequal(-1.0, 0.F) == false);
662 }
663 
test_isinf()664 void test_isinf()
665 {
666 #ifdef isinf
667 #error isinf defined
668 #endif
669     static_assert((std::is_same<decltype(isinf((float)0)), bool>::value), "");
670 
671     typedef decltype(isinf((double)0)) DoubleRetType;
672 #ifndef __linux__
673     static_assert((std::is_same<DoubleRetType, bool>::value), "");
674 #else
675     // GLIBC < 2.26 defines 'isinf(double)' with a return type of 'int' in
676     // all C++ dialects. The test should tolerate this.
677     // See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439
678     static_assert((std::is_same<DoubleRetType, bool>::value
679                 || std::is_same<DoubleRetType, int>::value), "");
680 #endif
681 
682     static_assert((std::is_same<decltype(isinf(0)), bool>::value), "");
683     static_assert((std::is_same<decltype(isinf((long double)0)), bool>::value), "");
684     assert(isinf(-1.0) == false);
685 }
686 
test_isless()687 void test_isless()
688 {
689 #ifdef isless
690 #error isless defined
691 #endif
692     static_assert((std::is_same<decltype(isless((float)0, (float)0)), bool>::value), "");
693     static_assert((std::is_same<decltype(isless((float)0, (double)0)), bool>::value), "");
694     static_assert((std::is_same<decltype(isless((float)0, (long double)0)), bool>::value), "");
695     static_assert((std::is_same<decltype(isless((double)0, (float)0)), bool>::value), "");
696     static_assert((std::is_same<decltype(isless((double)0, (double)0)), bool>::value), "");
697     static_assert((std::is_same<decltype(isless(0, (double)0)), bool>::value), "");
698     static_assert((std::is_same<decltype(isless((double)0, (long double)0)), bool>::value), "");
699     static_assert((std::is_same<decltype(isless((long double)0, (float)0)), bool>::value), "");
700     static_assert((std::is_same<decltype(isless((long double)0, (double)0)), bool>::value), "");
701     static_assert((std::is_same<decltype(isless((long double)0, (long double)0)), bool>::value), "");
702     static_assert((std::is_same<decltype(isless(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
703     assert(isless(-1.0, 0.F) == true);
704 }
705 
test_islessequal()706 void test_islessequal()
707 {
708 #ifdef islessequal
709 #error islessequal defined
710 #endif
711     static_assert((std::is_same<decltype(islessequal((float)0, (float)0)), bool>::value), "");
712     static_assert((std::is_same<decltype(islessequal((float)0, (double)0)), bool>::value), "");
713     static_assert((std::is_same<decltype(islessequal((float)0, (long double)0)), bool>::value), "");
714     static_assert((std::is_same<decltype(islessequal((double)0, (float)0)), bool>::value), "");
715     static_assert((std::is_same<decltype(islessequal((double)0, (double)0)), bool>::value), "");
716     static_assert((std::is_same<decltype(islessequal(0, (double)0)), bool>::value), "");
717     static_assert((std::is_same<decltype(islessequal((double)0, (long double)0)), bool>::value), "");
718     static_assert((std::is_same<decltype(islessequal((long double)0, (float)0)), bool>::value), "");
719     static_assert((std::is_same<decltype(islessequal((long double)0, (double)0)), bool>::value), "");
720     static_assert((std::is_same<decltype(islessequal((long double)0, (long double)0)), bool>::value), "");
721     static_assert((std::is_same<decltype(islessequal(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
722     assert(islessequal(-1.0, 0.F) == true);
723 }
724 
test_islessgreater()725 void test_islessgreater()
726 {
727 #ifdef islessgreater
728 #error islessgreater defined
729 #endif
730     static_assert((std::is_same<decltype(islessgreater((float)0, (float)0)), bool>::value), "");
731     static_assert((std::is_same<decltype(islessgreater((float)0, (double)0)), bool>::value), "");
732     static_assert((std::is_same<decltype(islessgreater((float)0, (long double)0)), bool>::value), "");
733     static_assert((std::is_same<decltype(islessgreater((double)0, (float)0)), bool>::value), "");
734     static_assert((std::is_same<decltype(islessgreater((double)0, (double)0)), bool>::value), "");
735     static_assert((std::is_same<decltype(islessgreater(0, (double)0)), bool>::value), "");
736     static_assert((std::is_same<decltype(islessgreater((double)0, (long double)0)), bool>::value), "");
737     static_assert((std::is_same<decltype(islessgreater((long double)0, (float)0)), bool>::value), "");
738     static_assert((std::is_same<decltype(islessgreater((long double)0, (double)0)), bool>::value), "");
739     static_assert((std::is_same<decltype(islessgreater((long double)0, (long double)0)), bool>::value), "");
740     static_assert((std::is_same<decltype(islessgreater(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
741     assert(islessgreater(-1.0, 0.F) == true);
742 }
743 
test_isnan()744 void test_isnan()
745 {
746 #ifdef isnan
747 #error isnan defined
748 #endif
749     static_assert((std::is_same<decltype(isnan((float)0)), bool>::value), "");
750 
751     typedef decltype(isnan((double)0)) DoubleRetType;
752 #ifndef __linux__
753     static_assert((std::is_same<DoubleRetType, bool>::value), "");
754 #else
755     // GLIBC < 2.26 defines 'isnan(double)' with a return type of 'int' in
756     // all C++ dialects. The test should tolerate this.
757     // See: https://sourceware.org/bugzilla/show_bug.cgi?id=19439
758     static_assert((std::is_same<DoubleRetType, bool>::value
759                 || std::is_same<DoubleRetType, int>::value), "");
760 #endif
761 
762     static_assert((std::is_same<decltype(isnan(0)), bool>::value), "");
763     static_assert((std::is_same<decltype(isnan((long double)0)), bool>::value), "");
764     assert(isnan(-1.0) == false);
765 }
766 
test_isunordered()767 void test_isunordered()
768 {
769 #ifdef isunordered
770 #error isunordered defined
771 #endif
772     static_assert((std::is_same<decltype(isunordered((float)0, (float)0)), bool>::value), "");
773     static_assert((std::is_same<decltype(isunordered((float)0, (double)0)), bool>::value), "");
774     static_assert((std::is_same<decltype(isunordered((float)0, (long double)0)), bool>::value), "");
775     static_assert((std::is_same<decltype(isunordered((double)0, (float)0)), bool>::value), "");
776     static_assert((std::is_same<decltype(isunordered((double)0, (double)0)), bool>::value), "");
777     static_assert((std::is_same<decltype(isunordered(0, (double)0)), bool>::value), "");
778     static_assert((std::is_same<decltype(isunordered((double)0, (long double)0)), bool>::value), "");
779     static_assert((std::is_same<decltype(isunordered((long double)0, (float)0)), bool>::value), "");
780     static_assert((std::is_same<decltype(isunordered((long double)0, (double)0)), bool>::value), "");
781     static_assert((std::is_same<decltype(isunordered((long double)0, (long double)0)), bool>::value), "");
782     static_assert((std::is_same<decltype(isunordered(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
783     assert(isunordered(-1.0, 0.F) == false);
784 }
785 
test_acosh()786 void test_acosh()
787 {
788     static_assert((std::is_same<decltype(acosh((float)0)), float>::value), "");
789     static_assert((std::is_same<decltype(acosh((bool)0)), double>::value), "");
790     static_assert((std::is_same<decltype(acosh((unsigned short)0)), double>::value), "");
791     static_assert((std::is_same<decltype(acosh((int)0)), double>::value), "");
792     static_assert((std::is_same<decltype(acosh((unsigned int)0)), double>::value), "");
793     static_assert((std::is_same<decltype(acosh((long)0)), double>::value), "");
794     static_assert((std::is_same<decltype(acosh((unsigned long)0)), double>::value), "");
795     static_assert((std::is_same<decltype(acosh((long long)0)), double>::value), "");
796     static_assert((std::is_same<decltype(acosh((unsigned long long)0)), double>::value), "");
797     static_assert((std::is_same<decltype(acosh((double)0)), double>::value), "");
798     static_assert((std::is_same<decltype(acosh((long double)0)), long double>::value), "");
799     static_assert((std::is_same<decltype(acoshf(0)), float>::value), "");
800     static_assert((std::is_same<decltype(acoshl(0)), long double>::value), "");
801     static_assert((std::is_same<decltype(acosh(Ambiguous())), Ambiguous>::value), "");
802     assert(acosh(1) == 0);
803 }
804 
test_asinh()805 void test_asinh()
806 {
807     static_assert((std::is_same<decltype(asinh((float)0)), float>::value), "");
808     static_assert((std::is_same<decltype(asinh((bool)0)), double>::value), "");
809     static_assert((std::is_same<decltype(asinh((unsigned short)0)), double>::value), "");
810     static_assert((std::is_same<decltype(asinh((int)0)), double>::value), "");
811     static_assert((std::is_same<decltype(asinh((unsigned int)0)), double>::value), "");
812     static_assert((std::is_same<decltype(asinh((long)0)), double>::value), "");
813     static_assert((std::is_same<decltype(asinh((unsigned long)0)), double>::value), "");
814     static_assert((std::is_same<decltype(asinh((long long)0)), double>::value), "");
815     static_assert((std::is_same<decltype(asinh((unsigned long long)0)), double>::value), "");
816     static_assert((std::is_same<decltype(asinh((double)0)), double>::value), "");
817     static_assert((std::is_same<decltype(asinh((long double)0)), long double>::value), "");
818     static_assert((std::is_same<decltype(asinhf(0)), float>::value), "");
819     static_assert((std::is_same<decltype(asinhl(0)), long double>::value), "");
820     static_assert((std::is_same<decltype(asinh(Ambiguous())), Ambiguous>::value), "");
821     assert(asinh(0) == 0);
822 }
823 
test_atanh()824 void test_atanh()
825 {
826     static_assert((std::is_same<decltype(atanh((float)0)), float>::value), "");
827     static_assert((std::is_same<decltype(atanh((bool)0)), double>::value), "");
828     static_assert((std::is_same<decltype(atanh((unsigned short)0)), double>::value), "");
829     static_assert((std::is_same<decltype(atanh((int)0)), double>::value), "");
830     static_assert((std::is_same<decltype(atanh((unsigned int)0)), double>::value), "");
831     static_assert((std::is_same<decltype(atanh((long)0)), double>::value), "");
832     static_assert((std::is_same<decltype(atanh((unsigned long)0)), double>::value), "");
833     static_assert((std::is_same<decltype(atanh((long long)0)), double>::value), "");
834     static_assert((std::is_same<decltype(atanh((unsigned long long)0)), double>::value), "");
835     static_assert((std::is_same<decltype(atanh((double)0)), double>::value), "");
836     static_assert((std::is_same<decltype(atanh((long double)0)), long double>::value), "");
837     static_assert((std::is_same<decltype(atanhf(0)), float>::value), "");
838     static_assert((std::is_same<decltype(atanhl(0)), long double>::value), "");
839     static_assert((std::is_same<decltype(atanh(Ambiguous())), Ambiguous>::value), "");
840     assert(atanh(0) == 0);
841 }
842 
test_cbrt()843 void test_cbrt() {
844     static_assert((std::is_same<decltype(cbrt((float) 0)), float>::value), "");
845     static_assert((std::is_same<decltype(cbrt((bool) 0)), double>::value), "");
846     static_assert((std::is_same<decltype(cbrt((unsigned short) 0)),
847                                 double>::value), "");
848     static_assert((std::is_same<decltype(cbrt((int) 0)), double>::value), "");
849     static_assert((std::is_same<decltype(cbrt((unsigned int) 0)),
850                                 double>::value), "");
851     static_assert((std::is_same<decltype(cbrt((long) 0)), double>::value), "");
852     static_assert((std::is_same<decltype(cbrt((unsigned long) 0)),
853                                 double>::value), "");
854     static_assert((std::is_same<decltype(cbrt((long long) 0)), double>::value),
855                   "");
856     static_assert((std::is_same<decltype(cbrt((unsigned long long) 0)),
857                                 double>::value), "");
858     static_assert((std::is_same<decltype(cbrt((double) 0)), double>::value),
859                   "");
860     static_assert((std::is_same<decltype(cbrt((long double) 0)),
861                                 long double>::value), "");
862     static_assert((std::is_same<decltype(cbrtf(0)), float>::value), "");
863     static_assert((std::is_same<decltype(cbrtl(0)), long double>::value), "");
864     static_assert((std::is_same<decltype(cbrt(Ambiguous())), Ambiguous>::value),
865                   "");
866     assert(truncate_fp(cbrt(1)) == 1);
867 
868 }
869 
test_copysign()870 void test_copysign()
871 {
872     static_assert((std::is_same<decltype(copysign((float)0, (float)0)), float>::value), "");
873     static_assert((std::is_same<decltype(copysign((bool)0, (float)0)), double>::value), "");
874     static_assert((std::is_same<decltype(copysign((unsigned short)0, (double)0)), double>::value), "");
875     static_assert((std::is_same<decltype(copysign((int)0, (long double)0)), long double>::value), "");
876     static_assert((std::is_same<decltype(copysign((float)0, (unsigned int)0)), double>::value), "");
877     static_assert((std::is_same<decltype(copysign((double)0, (long)0)), double>::value), "");
878     static_assert((std::is_same<decltype(copysign((long double)0, (unsigned long)0)), long double>::value), "");
879     static_assert((std::is_same<decltype(copysign((int)0, (long long)0)), double>::value), "");
880     static_assert((std::is_same<decltype(copysign((int)0, (unsigned long long)0)), double>::value), "");
881     static_assert((std::is_same<decltype(copysign((double)0, (double)0)), double>::value), "");
882     static_assert((std::is_same<decltype(copysign((long double)0, (long double)0)), long double>::value), "");
883     static_assert((std::is_same<decltype(copysign((float)0, (double)0)), double>::value), "");
884     static_assert((std::is_same<decltype(copysign((float)0, (long double)0)), long double>::value), "");
885     static_assert((std::is_same<decltype(copysign((double)0, (long double)0)), long double>::value), "");
886     static_assert((std::is_same<decltype(copysignf(0,0)), float>::value), "");
887     static_assert((std::is_same<decltype(copysignl(0,0)), long double>::value), "");
888     static_assert((std::is_same<decltype(copysign((int)0, (int)0)), double>::value), "");
889     static_assert((std::is_same<decltype(copysign(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
890     assert(copysign(1,1) == 1);
891 }
892 
test_erf()893 void test_erf()
894 {
895     static_assert((std::is_same<decltype(erf((float)0)), float>::value), "");
896     static_assert((std::is_same<decltype(erf((bool)0)), double>::value), "");
897     static_assert((std::is_same<decltype(erf((unsigned short)0)), double>::value), "");
898     static_assert((std::is_same<decltype(erf((int)0)), double>::value), "");
899     static_assert((std::is_same<decltype(erf((unsigned int)0)), double>::value), "");
900     static_assert((std::is_same<decltype(erf((long)0)), double>::value), "");
901     static_assert((std::is_same<decltype(erf((unsigned long)0)), double>::value), "");
902     static_assert((std::is_same<decltype(erf((long long)0)), double>::value), "");
903     static_assert((std::is_same<decltype(erf((unsigned long long)0)), double>::value), "");
904     static_assert((std::is_same<decltype(erf((double)0)), double>::value), "");
905     static_assert((std::is_same<decltype(erf((long double)0)), long double>::value), "");
906     static_assert((std::is_same<decltype(erff(0)), float>::value), "");
907     static_assert((std::is_same<decltype(erfl(0)), long double>::value), "");
908     static_assert((std::is_same<decltype(erf(Ambiguous())), Ambiguous>::value), "");
909     assert(erf(0) == 0);
910 }
911 
test_erfc()912 void test_erfc()
913 {
914     static_assert((std::is_same<decltype(erfc((float)0)), float>::value), "");
915     static_assert((std::is_same<decltype(erfc((bool)0)), double>::value), "");
916     static_assert((std::is_same<decltype(erfc((unsigned short)0)), double>::value), "");
917     static_assert((std::is_same<decltype(erfc((int)0)), double>::value), "");
918     static_assert((std::is_same<decltype(erfc((unsigned int)0)), double>::value), "");
919     static_assert((std::is_same<decltype(erfc((long)0)), double>::value), "");
920     static_assert((std::is_same<decltype(erfc((unsigned long)0)), double>::value), "");
921     static_assert((std::is_same<decltype(erfc((long long)0)), double>::value), "");
922     static_assert((std::is_same<decltype(erfc((unsigned long long)0)), double>::value), "");
923     static_assert((std::is_same<decltype(erfc((double)0)), double>::value), "");
924     static_assert((std::is_same<decltype(erfc((long double)0)), long double>::value), "");
925     static_assert((std::is_same<decltype(erfcf(0)), float>::value), "");
926     static_assert((std::is_same<decltype(erfcl(0)), long double>::value), "");
927     static_assert((std::is_same<decltype(erfc(Ambiguous())), Ambiguous>::value), "");
928     assert(erfc(0) == 1);
929 }
930 
test_exp2()931 void test_exp2()
932 {
933     static_assert((std::is_same<decltype(exp2((float)0)), float>::value), "");
934     static_assert((std::is_same<decltype(exp2((bool)0)), double>::value), "");
935     static_assert((std::is_same<decltype(exp2((unsigned short)0)), double>::value), "");
936     static_assert((std::is_same<decltype(exp2((int)0)), double>::value), "");
937     static_assert((std::is_same<decltype(exp2((unsigned int)0)), double>::value), "");
938     static_assert((std::is_same<decltype(exp2((long)0)), double>::value), "");
939     static_assert((std::is_same<decltype(exp2((unsigned long)0)), double>::value), "");
940     static_assert((std::is_same<decltype(exp2((long long)0)), double>::value), "");
941     static_assert((std::is_same<decltype(exp2((unsigned long long)0)), double>::value), "");
942     static_assert((std::is_same<decltype(exp2((double)0)), double>::value), "");
943     static_assert((std::is_same<decltype(exp2((long double)0)), long double>::value), "");
944     static_assert((std::is_same<decltype(exp2f(0)), float>::value), "");
945     static_assert((std::is_same<decltype(exp2l(0)), long double>::value), "");
946     static_assert((std::is_same<decltype(exp2(Ambiguous())), Ambiguous>::value), "");
947     assert(exp2(1) == 2);
948 }
949 
test_expm1()950 void test_expm1()
951 {
952     static_assert((std::is_same<decltype(expm1((float)0)), float>::value), "");
953     static_assert((std::is_same<decltype(expm1((bool)0)), double>::value), "");
954     static_assert((std::is_same<decltype(expm1((unsigned short)0)), double>::value), "");
955     static_assert((std::is_same<decltype(expm1((int)0)), double>::value), "");
956     static_assert((std::is_same<decltype(expm1((unsigned int)0)), double>::value), "");
957     static_assert((std::is_same<decltype(expm1((long)0)), double>::value), "");
958     static_assert((std::is_same<decltype(expm1((unsigned long)0)), double>::value), "");
959     static_assert((std::is_same<decltype(expm1((long long)0)), double>::value), "");
960     static_assert((std::is_same<decltype(expm1((unsigned long long)0)), double>::value), "");
961     static_assert((std::is_same<decltype(expm1((double)0)), double>::value), "");
962     static_assert((std::is_same<decltype(expm1((long double)0)), long double>::value), "");
963     static_assert((std::is_same<decltype(expm1f(0)), float>::value), "");
964     static_assert((std::is_same<decltype(expm1l(0)), long double>::value), "");
965     static_assert((std::is_same<decltype(expm1(Ambiguous())), Ambiguous>::value), "");
966     assert(expm1(0) == 0);
967 }
968 
test_fdim()969 void test_fdim()
970 {
971     static_assert((std::is_same<decltype(fdim((float)0, (float)0)), float>::value), "");
972     static_assert((std::is_same<decltype(fdim((bool)0, (float)0)), double>::value), "");
973     static_assert((std::is_same<decltype(fdim((unsigned short)0, (double)0)), double>::value), "");
974     static_assert((std::is_same<decltype(fdim((int)0, (long double)0)), long double>::value), "");
975     static_assert((std::is_same<decltype(fdim((float)0, (unsigned int)0)), double>::value), "");
976     static_assert((std::is_same<decltype(fdim((double)0, (long)0)), double>::value), "");
977     static_assert((std::is_same<decltype(fdim((long double)0, (unsigned long)0)), long double>::value), "");
978     static_assert((std::is_same<decltype(fdim((int)0, (long long)0)), double>::value), "");
979     static_assert((std::is_same<decltype(fdim((int)0, (unsigned long long)0)), double>::value), "");
980     static_assert((std::is_same<decltype(fdim((double)0, (double)0)), double>::value), "");
981     static_assert((std::is_same<decltype(fdim((long double)0, (long double)0)), long double>::value), "");
982     static_assert((std::is_same<decltype(fdim((float)0, (double)0)), double>::value), "");
983     static_assert((std::is_same<decltype(fdim((float)0, (long double)0)), long double>::value), "");
984     static_assert((std::is_same<decltype(fdim((double)0, (long double)0)), long double>::value), "");
985     static_assert((std::is_same<decltype(fdimf(0,0)), float>::value), "");
986     static_assert((std::is_same<decltype(fdiml(0,0)), long double>::value), "");
987     static_assert((std::is_same<decltype(fdim((int)0, (int)0)), double>::value), "");
988     static_assert((std::is_same<decltype(fdim(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
989     assert(fdim(1,0) == 1);
990 }
991 
test_fma()992 void test_fma()
993 {
994     static_assert((std::is_same<decltype(fma((bool)0, (float)0, (float)0)), double>::value), "");
995     static_assert((std::is_same<decltype(fma((char)0, (float)0, (float)0)), double>::value), "");
996     static_assert((std::is_same<decltype(fma((unsigned)0, (float)0, (float)0)), double>::value), "");
997     static_assert((std::is_same<decltype(fma((float)0, (int)0, (float)0)), double>::value), "");
998     static_assert((std::is_same<decltype(fma((float)0, (long)0, (float)0)), double>::value), "");
999     static_assert((std::is_same<decltype(fma((float)0, (float)0, (unsigned long long)0)), double>::value), "");
1000     static_assert((std::is_same<decltype(fma((float)0, (float)0, (double)0)), double>::value), "");
1001     static_assert((std::is_same<decltype(fma((float)0, (float)0, (long double)0)), long double>::value), "");
1002     static_assert((std::is_same<decltype(fma((float)0, (float)0, (float)0)), float>::value), "");
1003 
1004     static_assert((std::is_same<decltype(fma((bool)0, (double)0, (double)0)), double>::value), "");
1005     static_assert((std::is_same<decltype(fma((char)0, (double)0, (double)0)), double>::value), "");
1006     static_assert((std::is_same<decltype(fma((unsigned)0, (double)0, (double)0)), double>::value), "");
1007     static_assert((std::is_same<decltype(fma((double)0, (int)0, (double)0)), double>::value), "");
1008     static_assert((std::is_same<decltype(fma((double)0, (long)0, (double)0)), double>::value), "");
1009     static_assert((std::is_same<decltype(fma((double)0, (double)0, (unsigned long long)0)), double>::value), "");
1010     static_assert((std::is_same<decltype(fma((double)0, (double)0, (float)0)), double>::value), "");
1011     static_assert((std::is_same<decltype(fma((double)0, (double)0, (long double)0)), long double>::value), "");
1012     static_assert((std::is_same<decltype(fma((double)0, (double)0,  (double)0)), double>::value), "");
1013 
1014     static_assert((std::is_same<decltype(fma((bool)0, (long double)0, (long double)0)), long double>::value), "");
1015     static_assert((std::is_same<decltype(fma((char)0, (long double)0, (long double)0)), long double>::value), "");
1016     static_assert((std::is_same<decltype(fma((unsigned)0, (long double)0, (long double)0)), long double>::value), "");
1017     static_assert((std::is_same<decltype(fma((long double)0, (int)0, (long double)0)), long double>::value), "");
1018     static_assert((std::is_same<decltype(fma((long double)0, (long)0, (long double)0)), long double>::value), "");
1019     static_assert((std::is_same<decltype(fma((long double)0, (long double)0, (unsigned long long)0)), long double>::value), "");
1020     static_assert((std::is_same<decltype(fma((long double)0, (long double)0, (float)0)), long double>::value), "");
1021     static_assert((std::is_same<decltype(fma((double)0, (long double)0, (long double)0)), long double>::value), "");
1022     static_assert((std::is_same<decltype(fma((long double)0, (long double)0, (long double)0)), long double>::value), "");
1023 
1024     static_assert((std::is_same<decltype(fmaf(0,0,0)), float>::value), "");
1025     static_assert((std::is_same<decltype(fmal(0,0,0)), long double>::value), "");
1026     static_assert((std::is_same<decltype(fma(Ambiguous(), Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1027     assert(fma(1,1,1) == 2);
1028 }
1029 
test_fmax()1030 void test_fmax()
1031 {
1032     static_assert((std::is_same<decltype(fmax((float)0, (float)0)), float>::value), "");
1033     static_assert((std::is_same<decltype(fmax((bool)0, (float)0)), double>::value), "");
1034     static_assert((std::is_same<decltype(fmax((unsigned short)0, (double)0)), double>::value), "");
1035     static_assert((std::is_same<decltype(fmax((int)0, (long double)0)), long double>::value), "");
1036     static_assert((std::is_same<decltype(fmax((float)0, (unsigned int)0)), double>::value), "");
1037     static_assert((std::is_same<decltype(fmax((double)0, (long)0)), double>::value), "");
1038     static_assert((std::is_same<decltype(fmax((long double)0, (unsigned long)0)), long double>::value), "");
1039     static_assert((std::is_same<decltype(fmax((int)0, (long long)0)), double>::value), "");
1040     static_assert((std::is_same<decltype(fmax((int)0, (unsigned long long)0)), double>::value), "");
1041     static_assert((std::is_same<decltype(fmax((double)0, (double)0)), double>::value), "");
1042     static_assert((std::is_same<decltype(fmax((long double)0, (long double)0)), long double>::value), "");
1043     static_assert((std::is_same<decltype(fmax((float)0, (double)0)), double>::value), "");
1044     static_assert((std::is_same<decltype(fmax((float)0, (long double)0)), long double>::value), "");
1045     static_assert((std::is_same<decltype(fmax((double)0, (long double)0)), long double>::value), "");
1046     static_assert((std::is_same<decltype(fmaxf(0,0)), float>::value), "");
1047     static_assert((std::is_same<decltype(fmaxl(0,0)), long double>::value), "");
1048     static_assert((std::is_same<decltype(fmax((int)0, (int)0)), double>::value), "");
1049     static_assert((std::is_same<decltype(fmax(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1050     assert(fmax(1,0) == 1);
1051 }
1052 
test_fmin()1053 void test_fmin()
1054 {
1055     static_assert((std::is_same<decltype(fmin((float)0, (float)0)), float>::value), "");
1056     static_assert((std::is_same<decltype(fmin((bool)0, (float)0)), double>::value), "");
1057     static_assert((std::is_same<decltype(fmin((unsigned short)0, (double)0)), double>::value), "");
1058     static_assert((std::is_same<decltype(fmin((int)0, (long double)0)), long double>::value), "");
1059     static_assert((std::is_same<decltype(fmin((float)0, (unsigned int)0)), double>::value), "");
1060     static_assert((std::is_same<decltype(fmin((double)0, (long)0)), double>::value), "");
1061     static_assert((std::is_same<decltype(fmin((long double)0, (unsigned long)0)), long double>::value), "");
1062     static_assert((std::is_same<decltype(fmin((int)0, (long long)0)), double>::value), "");
1063     static_assert((std::is_same<decltype(fmin((int)0, (unsigned long long)0)), double>::value), "");
1064     static_assert((std::is_same<decltype(fmin((double)0, (double)0)), double>::value), "");
1065     static_assert((std::is_same<decltype(fmin((long double)0, (long double)0)), long double>::value), "");
1066     static_assert((std::is_same<decltype(fmin((float)0, (double)0)), double>::value), "");
1067     static_assert((std::is_same<decltype(fmin((float)0, (long double)0)), long double>::value), "");
1068     static_assert((std::is_same<decltype(fmin((double)0, (long double)0)), long double>::value), "");
1069     static_assert((std::is_same<decltype(fminf(0,0)), float>::value), "");
1070     static_assert((std::is_same<decltype(fminl(0,0)), long double>::value), "");
1071     static_assert((std::is_same<decltype(fmin((int)0, (int)0)), double>::value), "");
1072     static_assert((std::is_same<decltype(fmin(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1073     assert(fmin(1,0) == 0);
1074 }
1075 
test_hypot()1076 void test_hypot()
1077 {
1078     static_assert((std::is_same<decltype(hypot((float)0, (float)0)), float>::value), "");
1079     static_assert((std::is_same<decltype(hypot((bool)0, (float)0)), double>::value), "");
1080     static_assert((std::is_same<decltype(hypot((unsigned short)0, (double)0)), double>::value), "");
1081     static_assert((std::is_same<decltype(hypot((int)0, (long double)0)), long double>::value), "");
1082     static_assert((std::is_same<decltype(hypot((float)0, (unsigned int)0)), double>::value), "");
1083     static_assert((std::is_same<decltype(hypot((double)0, (long)0)), double>::value), "");
1084     static_assert((std::is_same<decltype(hypot((long double)0, (unsigned long)0)), long double>::value), "");
1085     static_assert((std::is_same<decltype(hypot((int)0, (long long)0)), double>::value), "");
1086     static_assert((std::is_same<decltype(hypot((int)0, (unsigned long long)0)), double>::value), "");
1087     static_assert((std::is_same<decltype(hypot((double)0, (double)0)), double>::value), "");
1088     static_assert((std::is_same<decltype(hypot((long double)0, (long double)0)), long double>::value), "");
1089     static_assert((std::is_same<decltype(hypot((float)0, (double)0)), double>::value), "");
1090     static_assert((std::is_same<decltype(hypot((float)0, (long double)0)), long double>::value), "");
1091     static_assert((std::is_same<decltype(hypot((double)0, (long double)0)), long double>::value), "");
1092     static_assert((std::is_same<decltype(hypotf(0,0)), float>::value), "");
1093     static_assert((std::is_same<decltype(hypotl(0,0)), long double>::value), "");
1094     static_assert((std::is_same<decltype(hypot((int)0, (int)0)), double>::value), "");
1095     static_assert((std::is_same<decltype(hypot(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1096     assert(hypot(3,4) == 5);
1097 }
1098 
test_ilogb()1099 void test_ilogb()
1100 {
1101     static_assert((std::is_same<decltype(ilogb((float)0)), int>::value), "");
1102     static_assert((std::is_same<decltype(ilogb((bool)0)), int>::value), "");
1103     static_assert((std::is_same<decltype(ilogb((unsigned short)0)), int>::value), "");
1104     static_assert((std::is_same<decltype(ilogb((int)0)), int>::value), "");
1105     static_assert((std::is_same<decltype(ilogb((unsigned int)0)), int>::value), "");
1106     static_assert((std::is_same<decltype(ilogb((long)0)), int>::value), "");
1107     static_assert((std::is_same<decltype(ilogb((unsigned long)0)), int>::value), "");
1108     static_assert((std::is_same<decltype(ilogb((long long)0)), int>::value), "");
1109     static_assert((std::is_same<decltype(ilogb((unsigned long long)0)), int>::value), "");
1110     static_assert((std::is_same<decltype(ilogb((double)0)), int>::value), "");
1111     static_assert((std::is_same<decltype(ilogb((long double)0)), int>::value), "");
1112     static_assert((std::is_same<decltype(ilogbf(0)), int>::value), "");
1113     static_assert((std::is_same<decltype(ilogbl(0)), int>::value), "");
1114     static_assert((std::is_same<decltype(ilogb(Ambiguous())), Ambiguous>::value), "");
1115     assert(ilogb(1) == 0);
1116 }
1117 
test_lgamma()1118 void test_lgamma()
1119 {
1120     static_assert((std::is_same<decltype(lgamma((float)0)), float>::value), "");
1121     static_assert((std::is_same<decltype(lgamma((bool)0)), double>::value), "");
1122     static_assert((std::is_same<decltype(lgamma((unsigned short)0)), double>::value), "");
1123     static_assert((std::is_same<decltype(lgamma((int)0)), double>::value), "");
1124     static_assert((std::is_same<decltype(lgamma((unsigned int)0)), double>::value), "");
1125     static_assert((std::is_same<decltype(lgamma((long)0)), double>::value), "");
1126     static_assert((std::is_same<decltype(lgamma((unsigned long)0)), double>::value), "");
1127     static_assert((std::is_same<decltype(lgamma((long long)0)), double>::value), "");
1128     static_assert((std::is_same<decltype(lgamma((unsigned long long)0)), double>::value), "");
1129     static_assert((std::is_same<decltype(lgamma((double)0)), double>::value), "");
1130     static_assert((std::is_same<decltype(lgamma((long double)0)), long double>::value), "");
1131     static_assert((std::is_same<decltype(lgammaf(0)), float>::value), "");
1132     static_assert((std::is_same<decltype(lgammal(0)), long double>::value), "");
1133     static_assert((std::is_same<decltype(lgamma(Ambiguous())), Ambiguous>::value), "");
1134     assert(lgamma(1) == 0);
1135 }
1136 
test_llrint()1137 void test_llrint()
1138 {
1139     static_assert((std::is_same<decltype(llrint((float)0)), long long>::value), "");
1140     static_assert((std::is_same<decltype(llrint((bool)0)), long long>::value), "");
1141     static_assert((std::is_same<decltype(llrint((unsigned short)0)), long long>::value), "");
1142     static_assert((std::is_same<decltype(llrint((int)0)), long long>::value), "");
1143     static_assert((std::is_same<decltype(llrint((unsigned int)0)), long long>::value), "");
1144     static_assert((std::is_same<decltype(llrint((long)0)), long long>::value), "");
1145     static_assert((std::is_same<decltype(llrint((unsigned long)0)), long long>::value), "");
1146     static_assert((std::is_same<decltype(llrint((long long)0)), long long>::value), "");
1147     static_assert((std::is_same<decltype(llrint((unsigned long long)0)), long long>::value), "");
1148     static_assert((std::is_same<decltype(llrint((double)0)), long long>::value), "");
1149     static_assert((std::is_same<decltype(llrint((long double)0)), long long>::value), "");
1150     static_assert((std::is_same<decltype(llrintf(0)), long long>::value), "");
1151     static_assert((std::is_same<decltype(llrintl(0)), long long>::value), "");
1152     static_assert((std::is_same<decltype(llrint(Ambiguous())), Ambiguous>::value), "");
1153     assert(llrint(1) == 1LL);
1154 }
1155 
test_llround()1156 void test_llround()
1157 {
1158     static_assert((std::is_same<decltype(llround((float)0)), long long>::value), "");
1159     static_assert((std::is_same<decltype(llround((bool)0)), long long>::value), "");
1160     static_assert((std::is_same<decltype(llround((unsigned short)0)), long long>::value), "");
1161     static_assert((std::is_same<decltype(llround((int)0)), long long>::value), "");
1162     static_assert((std::is_same<decltype(llround((unsigned int)0)), long long>::value), "");
1163     static_assert((std::is_same<decltype(llround((long)0)), long long>::value), "");
1164     static_assert((std::is_same<decltype(llround((unsigned long)0)), long long>::value), "");
1165     static_assert((std::is_same<decltype(llround((long long)0)), long long>::value), "");
1166     static_assert((std::is_same<decltype(llround((unsigned long long)0)), long long>::value), "");
1167     static_assert((std::is_same<decltype(llround((double)0)), long long>::value), "");
1168     static_assert((std::is_same<decltype(llround((long double)0)), long long>::value), "");
1169     static_assert((std::is_same<decltype(llroundf(0)), long long>::value), "");
1170     static_assert((std::is_same<decltype(llroundl(0)), long long>::value), "");
1171     static_assert((std::is_same<decltype(llround(Ambiguous())), Ambiguous>::value), "");
1172     assert(llround(1) == 1LL);
1173 }
1174 
test_log1p()1175 void test_log1p()
1176 {
1177     static_assert((std::is_same<decltype(log1p((float)0)), float>::value), "");
1178     static_assert((std::is_same<decltype(log1p((bool)0)), double>::value), "");
1179     static_assert((std::is_same<decltype(log1p((unsigned short)0)), double>::value), "");
1180     static_assert((std::is_same<decltype(log1p((int)0)), double>::value), "");
1181     static_assert((std::is_same<decltype(log1p((unsigned int)0)), double>::value), "");
1182     static_assert((std::is_same<decltype(log1p((long)0)), double>::value), "");
1183     static_assert((std::is_same<decltype(log1p((unsigned long)0)), double>::value), "");
1184     static_assert((std::is_same<decltype(log1p((long long)0)), double>::value), "");
1185     static_assert((std::is_same<decltype(log1p((unsigned long long)0)), double>::value), "");
1186     static_assert((std::is_same<decltype(log1p((double)0)), double>::value), "");
1187     static_assert((std::is_same<decltype(log1p((long double)0)), long double>::value), "");
1188     static_assert((std::is_same<decltype(log1pf(0)), float>::value), "");
1189     static_assert((std::is_same<decltype(log1pl(0)), long double>::value), "");
1190     static_assert((std::is_same<decltype(log1p(Ambiguous())), Ambiguous>::value), "");
1191     assert(log1p(0) == 0);
1192 }
1193 
test_log2()1194 void test_log2()
1195 {
1196     static_assert((std::is_same<decltype(log2((float)0)), float>::value), "");
1197     static_assert((std::is_same<decltype(log2((bool)0)), double>::value), "");
1198     static_assert((std::is_same<decltype(log2((unsigned short)0)), double>::value), "");
1199     static_assert((std::is_same<decltype(log2((int)0)), double>::value), "");
1200     static_assert((std::is_same<decltype(log2((unsigned int)0)), double>::value), "");
1201     static_assert((std::is_same<decltype(log2((long)0)), double>::value), "");
1202     static_assert((std::is_same<decltype(log2((unsigned long)0)), double>::value), "");
1203     static_assert((std::is_same<decltype(log2((long long)0)), double>::value), "");
1204     static_assert((std::is_same<decltype(log2((unsigned long long)0)), double>::value), "");
1205     static_assert((std::is_same<decltype(log2((double)0)), double>::value), "");
1206     static_assert((std::is_same<decltype(log2((long double)0)), long double>::value), "");
1207     static_assert((std::is_same<decltype(log2f(0)), float>::value), "");
1208     static_assert((std::is_same<decltype(log2l(0)), long double>::value), "");
1209     static_assert((std::is_same<decltype(log2(Ambiguous())), Ambiguous>::value), "");
1210     assert(log2(1) == 0);
1211 }
1212 
test_logb()1213 void test_logb()
1214 {
1215     static_assert((std::is_same<decltype(logb((float)0)), float>::value), "");
1216     static_assert((std::is_same<decltype(logb((bool)0)), double>::value), "");
1217     static_assert((std::is_same<decltype(logb((unsigned short)0)), double>::value), "");
1218     static_assert((std::is_same<decltype(logb((int)0)), double>::value), "");
1219     static_assert((std::is_same<decltype(logb((unsigned int)0)), double>::value), "");
1220     static_assert((std::is_same<decltype(logb((long)0)), double>::value), "");
1221     static_assert((std::is_same<decltype(logb((unsigned long)0)), double>::value), "");
1222     static_assert((std::is_same<decltype(logb((long long)0)), double>::value), "");
1223     static_assert((std::is_same<decltype(logb((unsigned long long)0)), double>::value), "");
1224     static_assert((std::is_same<decltype(logb((double)0)), double>::value), "");
1225     static_assert((std::is_same<decltype(logb((long double)0)), long double>::value), "");
1226     static_assert((std::is_same<decltype(logbf(0)), float>::value), "");
1227     static_assert((std::is_same<decltype(logbl(0)), long double>::value), "");
1228     static_assert((std::is_same<decltype(logb(Ambiguous())), Ambiguous>::value), "");
1229     assert(logb(1) == 0);
1230 }
1231 
test_lrint()1232 void test_lrint()
1233 {
1234     static_assert((std::is_same<decltype(lrint((float)0)), long>::value), "");
1235     static_assert((std::is_same<decltype(lrint((bool)0)), long>::value), "");
1236     static_assert((std::is_same<decltype(lrint((unsigned short)0)), long>::value), "");
1237     static_assert((std::is_same<decltype(lrint((int)0)), long>::value), "");
1238     static_assert((std::is_same<decltype(lrint((unsigned int)0)), long>::value), "");
1239     static_assert((std::is_same<decltype(lrint((long)0)), long>::value), "");
1240     static_assert((std::is_same<decltype(lrint((unsigned long)0)), long>::value), "");
1241     static_assert((std::is_same<decltype(lrint((long long)0)), long>::value), "");
1242     static_assert((std::is_same<decltype(lrint((unsigned long long)0)), long>::value), "");
1243     static_assert((std::is_same<decltype(lrint((double)0)), long>::value), "");
1244     static_assert((std::is_same<decltype(lrint((long double)0)), long>::value), "");
1245     static_assert((std::is_same<decltype(lrintf(0)), long>::value), "");
1246     static_assert((std::is_same<decltype(lrintl(0)), long>::value), "");
1247     static_assert((std::is_same<decltype(lrint(Ambiguous())), Ambiguous>::value), "");
1248     assert(lrint(1) == 1L);
1249 }
1250 
test_lround()1251 void test_lround()
1252 {
1253     static_assert((std::is_same<decltype(lround((float)0)), long>::value), "");
1254     static_assert((std::is_same<decltype(lround((bool)0)), long>::value), "");
1255     static_assert((std::is_same<decltype(lround((unsigned short)0)), long>::value), "");
1256     static_assert((std::is_same<decltype(lround((int)0)), long>::value), "");
1257     static_assert((std::is_same<decltype(lround((unsigned int)0)), long>::value), "");
1258     static_assert((std::is_same<decltype(lround((long)0)), long>::value), "");
1259     static_assert((std::is_same<decltype(lround((unsigned long)0)), long>::value), "");
1260     static_assert((std::is_same<decltype(lround((long long)0)), long>::value), "");
1261     static_assert((std::is_same<decltype(lround((unsigned long long)0)), long>::value), "");
1262     static_assert((std::is_same<decltype(lround((double)0)), long>::value), "");
1263     static_assert((std::is_same<decltype(lround((long double)0)), long>::value), "");
1264     static_assert((std::is_same<decltype(lroundf(0)), long>::value), "");
1265     static_assert((std::is_same<decltype(lroundl(0)), long>::value), "");
1266     static_assert((std::is_same<decltype(lround(Ambiguous())), Ambiguous>::value), "");
1267     assert(lround(1) == 1L);
1268 }
1269 
test_nan()1270 void test_nan()
1271 {
1272     static_assert((std::is_same<decltype(nan("")), double>::value), "");
1273     static_assert((std::is_same<decltype(nanf("")), float>::value), "");
1274     static_assert((std::is_same<decltype(nanl("")), long double>::value), "");
1275 }
1276 
test_nearbyint()1277 void test_nearbyint()
1278 {
1279     static_assert((std::is_same<decltype(nearbyint((float)0)), float>::value), "");
1280     static_assert((std::is_same<decltype(nearbyint((bool)0)), double>::value), "");
1281     static_assert((std::is_same<decltype(nearbyint((unsigned short)0)), double>::value), "");
1282     static_assert((std::is_same<decltype(nearbyint((int)0)), double>::value), "");
1283     static_assert((std::is_same<decltype(nearbyint((unsigned int)0)), double>::value), "");
1284     static_assert((std::is_same<decltype(nearbyint((long)0)), double>::value), "");
1285     static_assert((std::is_same<decltype(nearbyint((unsigned long)0)), double>::value), "");
1286     static_assert((std::is_same<decltype(nearbyint((long long)0)), double>::value), "");
1287     static_assert((std::is_same<decltype(nearbyint((unsigned long long)0)), double>::value), "");
1288     static_assert((std::is_same<decltype(nearbyint((double)0)), double>::value), "");
1289     static_assert((std::is_same<decltype(nearbyint((long double)0)), long double>::value), "");
1290     static_assert((std::is_same<decltype(nearbyintf(0)), float>::value), "");
1291     static_assert((std::is_same<decltype(nearbyintl(0)), long double>::value), "");
1292     static_assert((std::is_same<decltype(nearbyint(Ambiguous())), Ambiguous>::value), "");
1293     assert(nearbyint(1) == 1);
1294 }
1295 
test_nextafter()1296 void test_nextafter()
1297 {
1298     static_assert((std::is_same<decltype(nextafter((float)0, (float)0)), float>::value), "");
1299     static_assert((std::is_same<decltype(nextafter((bool)0, (float)0)), double>::value), "");
1300     static_assert((std::is_same<decltype(nextafter((unsigned short)0, (double)0)), double>::value), "");
1301     static_assert((std::is_same<decltype(nextafter((int)0, (long double)0)), long double>::value), "");
1302     static_assert((std::is_same<decltype(nextafter((float)0, (unsigned int)0)), double>::value), "");
1303     static_assert((std::is_same<decltype(nextafter((double)0, (long)0)), double>::value), "");
1304     static_assert((std::is_same<decltype(nextafter((long double)0, (unsigned long)0)), long double>::value), "");
1305     static_assert((std::is_same<decltype(nextafter((int)0, (long long)0)), double>::value), "");
1306     static_assert((std::is_same<decltype(nextafter((int)0, (unsigned long long)0)), double>::value), "");
1307     static_assert((std::is_same<decltype(nextafter((double)0, (double)0)), double>::value), "");
1308     static_assert((std::is_same<decltype(nextafter((long double)0, (long double)0)), long double>::value), "");
1309     static_assert((std::is_same<decltype(nextafter((float)0, (double)0)), double>::value), "");
1310     static_assert((std::is_same<decltype(nextafter((float)0, (long double)0)), long double>::value), "");
1311     static_assert((std::is_same<decltype(nextafter((double)0, (long double)0)), long double>::value), "");
1312     static_assert((std::is_same<decltype(nextafterf(0,0)), float>::value), "");
1313     static_assert((std::is_same<decltype(nextafterl(0,0)), long double>::value), "");
1314     static_assert((std::is_same<decltype(nextafter((int)0, (int)0)), double>::value), "");
1315     static_assert((std::is_same<decltype(nextafter(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1316     assert(nextafter(0,1) == hexfloat<double>(0x1, 0, -1074));
1317 }
1318 
test_nexttoward()1319 void test_nexttoward()
1320 {
1321     static_assert((std::is_same<decltype(nexttoward((float)0, (long double)0)), float>::value), "");
1322     static_assert((std::is_same<decltype(nexttoward((bool)0, (long double)0)), double>::value), "");
1323     static_assert((std::is_same<decltype(nexttoward((unsigned short)0, (long double)0)), double>::value), "");
1324     static_assert((std::is_same<decltype(nexttoward((int)0, (long double)0)), double>::value), "");
1325     static_assert((std::is_same<decltype(nexttoward((unsigned int)0, (long double)0)), double>::value), "");
1326     static_assert((std::is_same<decltype(nexttoward((long)0, (long double)0)), double>::value), "");
1327     static_assert((std::is_same<decltype(nexttoward((unsigned long)0, (long double)0)), double>::value), "");
1328     static_assert((std::is_same<decltype(nexttoward((long long)0, (long double)0)), double>::value), "");
1329     static_assert((std::is_same<decltype(nexttoward((unsigned long long)0, (long double)0)), double>::value), "");
1330     static_assert((std::is_same<decltype(nexttoward((double)0, (long double)0)), double>::value), "");
1331     static_assert((std::is_same<decltype(nexttoward((long double)0, (long double)0)), long double>::value), "");
1332     static_assert((std::is_same<decltype(nexttowardf(0, (long double)0)), float>::value), "");
1333     static_assert((std::is_same<decltype(nexttowardl(0, (long double)0)), long double>::value), "");
1334     static_assert((std::is_same<decltype(nexttoward(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1335     assert(nexttoward(0, 1) == hexfloat<double>(0x1, 0, -1074));
1336 }
1337 
test_remainder()1338 void test_remainder()
1339 {
1340     static_assert((std::is_same<decltype(remainder((float)0, (float)0)), float>::value), "");
1341     static_assert((std::is_same<decltype(remainder((bool)0, (float)0)), double>::value), "");
1342     static_assert((std::is_same<decltype(remainder((unsigned short)0, (double)0)), double>::value), "");
1343     static_assert((std::is_same<decltype(remainder((int)0, (long double)0)), long double>::value), "");
1344     static_assert((std::is_same<decltype(remainder((float)0, (unsigned int)0)), double>::value), "");
1345     static_assert((std::is_same<decltype(remainder((double)0, (long)0)), double>::value), "");
1346     static_assert((std::is_same<decltype(remainder((long double)0, (unsigned long)0)), long double>::value), "");
1347     static_assert((std::is_same<decltype(remainder((int)0, (long long)0)), double>::value), "");
1348     static_assert((std::is_same<decltype(remainder((int)0, (unsigned long long)0)), double>::value), "");
1349     static_assert((std::is_same<decltype(remainder((double)0, (double)0)), double>::value), "");
1350     static_assert((std::is_same<decltype(remainder((long double)0, (long double)0)), long double>::value), "");
1351     static_assert((std::is_same<decltype(remainder((float)0, (double)0)), double>::value), "");
1352     static_assert((std::is_same<decltype(remainder((float)0, (long double)0)), long double>::value), "");
1353     static_assert((std::is_same<decltype(remainder((double)0, (long double)0)), long double>::value), "");
1354     static_assert((std::is_same<decltype(remainderf(0,0)), float>::value), "");
1355     static_assert((std::is_same<decltype(remainderl(0,0)), long double>::value), "");
1356     static_assert((std::is_same<decltype(remainder((int)0, (int)0)), double>::value), "");
1357     static_assert((std::is_same<decltype(remainder(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1358     assert(remainder(0.5,1) == 0.5);
1359 }
1360 
test_remquo()1361 void test_remquo()
1362 {
1363     int ip;
1364     static_assert((std::is_same<decltype(remquo((float)0, (float)0, &ip)), float>::value), "");
1365     static_assert((std::is_same<decltype(remquo((bool)0, (float)0, &ip)), double>::value), "");
1366     static_assert((std::is_same<decltype(remquo((unsigned short)0, (double)0, &ip)), double>::value), "");
1367     static_assert((std::is_same<decltype(remquo((int)0, (long double)0, &ip)), long double>::value), "");
1368     static_assert((std::is_same<decltype(remquo((float)0, (unsigned int)0, &ip)), double>::value), "");
1369     static_assert((std::is_same<decltype(remquo((double)0, (long)0, &ip)), double>::value), "");
1370     static_assert((std::is_same<decltype(remquo((long double)0, (unsigned long)0, &ip)), long double>::value), "");
1371     static_assert((std::is_same<decltype(remquo((int)0, (long long)0, &ip)), double>::value), "");
1372     static_assert((std::is_same<decltype(remquo((int)0, (unsigned long long)0, &ip)), double>::value), "");
1373     static_assert((std::is_same<decltype(remquo((double)0, (double)0, &ip)), double>::value), "");
1374     static_assert((std::is_same<decltype(remquo((long double)0, (long double)0, &ip)), long double>::value), "");
1375     static_assert((std::is_same<decltype(remquo((float)0, (double)0, &ip)), double>::value), "");
1376     static_assert((std::is_same<decltype(remquo((float)0, (long double)0, &ip)), long double>::value), "");
1377     static_assert((std::is_same<decltype(remquo((double)0, (long double)0, &ip)), long double>::value), "");
1378     static_assert((std::is_same<decltype(remquof(0,0, &ip)), float>::value), "");
1379     static_assert((std::is_same<decltype(remquol(0,0, &ip)), long double>::value), "");
1380     static_assert((std::is_same<decltype(remquo((int)0, (int)0, &ip)), double>::value), "");
1381     static_assert((std::is_same<decltype(remquo(Ambiguous(), Ambiguous(), &ip)), Ambiguous>::value), "");
1382     assert(remquo(0.5,1, &ip) == 0.5);
1383 }
1384 
test_rint()1385 void test_rint()
1386 {
1387     static_assert((std::is_same<decltype(rint((float)0)), float>::value), "");
1388     static_assert((std::is_same<decltype(rint((bool)0)), double>::value), "");
1389     static_assert((std::is_same<decltype(rint((unsigned short)0)), double>::value), "");
1390     static_assert((std::is_same<decltype(rint((int)0)), double>::value), "");
1391     static_assert((std::is_same<decltype(rint((unsigned int)0)), double>::value), "");
1392     static_assert((std::is_same<decltype(rint((long)0)), double>::value), "");
1393     static_assert((std::is_same<decltype(rint((unsigned long)0)), double>::value), "");
1394     static_assert((std::is_same<decltype(rint((long long)0)), double>::value), "");
1395     static_assert((std::is_same<decltype(rint((unsigned long long)0)), double>::value), "");
1396     static_assert((std::is_same<decltype(rint((double)0)), double>::value), "");
1397     static_assert((std::is_same<decltype(rint((long double)0)), long double>::value), "");
1398     static_assert((std::is_same<decltype(rintf(0)), float>::value), "");
1399     static_assert((std::is_same<decltype(rintl(0)), long double>::value), "");
1400     static_assert((std::is_same<decltype(rint(Ambiguous())), Ambiguous>::value), "");
1401     assert(rint(1) == 1);
1402 }
1403 
test_round()1404 void test_round()
1405 {
1406     static_assert((std::is_same<decltype(round((float)0)), float>::value), "");
1407     static_assert((std::is_same<decltype(round((bool)0)), double>::value), "");
1408     static_assert((std::is_same<decltype(round((unsigned short)0)), double>::value), "");
1409     static_assert((std::is_same<decltype(round((int)0)), double>::value), "");
1410     static_assert((std::is_same<decltype(round((unsigned int)0)), double>::value), "");
1411     static_assert((std::is_same<decltype(round((long)0)), double>::value), "");
1412     static_assert((std::is_same<decltype(round((unsigned long)0)), double>::value), "");
1413     static_assert((std::is_same<decltype(round((long long)0)), double>::value), "");
1414     static_assert((std::is_same<decltype(round((unsigned long long)0)), double>::value), "");
1415     static_assert((std::is_same<decltype(round((double)0)), double>::value), "");
1416     static_assert((std::is_same<decltype(round((long double)0)), long double>::value), "");
1417     static_assert((std::is_same<decltype(roundf(0)), float>::value), "");
1418     static_assert((std::is_same<decltype(roundl(0)), long double>::value), "");
1419     static_assert((std::is_same<decltype(round(Ambiguous())), Ambiguous>::value), "");
1420     assert(round(1) == 1);
1421 }
1422 
test_scalbln()1423 void test_scalbln()
1424 {
1425     static_assert((std::is_same<decltype(scalbln((float)0, (long)0)), float>::value), "");
1426     static_assert((std::is_same<decltype(scalbln((bool)0, (long)0)), double>::value), "");
1427     static_assert((std::is_same<decltype(scalbln((unsigned short)0, (long)0)), double>::value), "");
1428     static_assert((std::is_same<decltype(scalbln((int)0, (long)0)), double>::value), "");
1429     static_assert((std::is_same<decltype(scalbln((unsigned int)0, (long)0)), double>::value), "");
1430     static_assert((std::is_same<decltype(scalbln((long)0, (long)0)), double>::value), "");
1431     static_assert((std::is_same<decltype(scalbln((unsigned long)0, (long)0)), double>::value), "");
1432     static_assert((std::is_same<decltype(scalbln((long long)0, (long)0)), double>::value), "");
1433     static_assert((std::is_same<decltype(scalbln((unsigned long long)0, (long)0)), double>::value), "");
1434     static_assert((std::is_same<decltype(scalbln((double)0, (long)0)), double>::value), "");
1435     static_assert((std::is_same<decltype(scalbln((long double)0, (long)0)), long double>::value), "");
1436     static_assert((std::is_same<decltype(scalblnf(0, (long)0)), float>::value), "");
1437     static_assert((std::is_same<decltype(scalblnl(0, (long)0)), long double>::value), "");
1438     static_assert((std::is_same<decltype(scalbln(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1439     assert(scalbln(1, 1) == 2);
1440 }
1441 
test_scalbn()1442 void test_scalbn()
1443 {
1444     static_assert((std::is_same<decltype(scalbn((float)0, (int)0)), float>::value), "");
1445     static_assert((std::is_same<decltype(scalbn((bool)0, (int)0)), double>::value), "");
1446     static_assert((std::is_same<decltype(scalbn((unsigned short)0, (int)0)), double>::value), "");
1447     static_assert((std::is_same<decltype(scalbn((int)0, (int)0)), double>::value), "");
1448     static_assert((std::is_same<decltype(scalbn((unsigned int)0, (int)0)), double>::value), "");
1449     static_assert((std::is_same<decltype(scalbn((long)0, (int)0)), double>::value), "");
1450     static_assert((std::is_same<decltype(scalbn((unsigned long)0, (int)0)), double>::value), "");
1451     static_assert((std::is_same<decltype(scalbn((long long)0, (int)0)), double>::value), "");
1452     static_assert((std::is_same<decltype(scalbn((unsigned long long)0, (int)0)), double>::value), "");
1453     static_assert((std::is_same<decltype(scalbn((double)0, (int)0)), double>::value), "");
1454     static_assert((std::is_same<decltype(scalbn((long double)0, (int)0)), long double>::value), "");
1455     static_assert((std::is_same<decltype(scalbnf(0, (int)0)), float>::value), "");
1456     static_assert((std::is_same<decltype(scalbnl(0, (int)0)), long double>::value), "");
1457     static_assert((std::is_same<decltype(scalbn(Ambiguous(), Ambiguous())), Ambiguous>::value), "");
1458     assert(scalbn(1, 1) == 2);
1459 }
1460 
test_tgamma()1461 void test_tgamma()
1462 {
1463     static_assert((std::is_same<decltype(tgamma((float)0)), float>::value), "");
1464     static_assert((std::is_same<decltype(tgamma((bool)0)), double>::value), "");
1465     static_assert((std::is_same<decltype(tgamma((unsigned short)0)), double>::value), "");
1466     static_assert((std::is_same<decltype(tgamma((int)0)), double>::value), "");
1467     static_assert((std::is_same<decltype(tgamma((unsigned int)0)), double>::value), "");
1468     static_assert((std::is_same<decltype(tgamma((long)0)), double>::value), "");
1469     static_assert((std::is_same<decltype(tgamma((unsigned long)0)), double>::value), "");
1470     static_assert((std::is_same<decltype(tgamma((long long)0)), double>::value), "");
1471     static_assert((std::is_same<decltype(tgamma((unsigned long long)0)), double>::value), "");
1472     static_assert((std::is_same<decltype(tgamma((double)0)), double>::value), "");
1473     static_assert((std::is_same<decltype(tgamma((long double)0)), long double>::value), "");
1474     static_assert((std::is_same<decltype(tgammaf(0)), float>::value), "");
1475     static_assert((std::is_same<decltype(tgammal(0)), long double>::value), "");
1476     static_assert((std::is_same<decltype(tgamma(Ambiguous())), Ambiguous>::value), "");
1477     assert(tgamma(1) == 1);
1478 }
1479 
test_trunc()1480 void test_trunc()
1481 {
1482     static_assert((std::is_same<decltype(trunc((float)0)), float>::value), "");
1483     static_assert((std::is_same<decltype(trunc((bool)0)), double>::value), "");
1484     static_assert((std::is_same<decltype(trunc((unsigned short)0)), double>::value), "");
1485     static_assert((std::is_same<decltype(trunc((int)0)), double>::value), "");
1486     static_assert((std::is_same<decltype(trunc((unsigned int)0)), double>::value), "");
1487     static_assert((std::is_same<decltype(trunc((long)0)), double>::value), "");
1488     static_assert((std::is_same<decltype(trunc((unsigned long)0)), double>::value), "");
1489     static_assert((std::is_same<decltype(trunc((long long)0)), double>::value), "");
1490     static_assert((std::is_same<decltype(trunc((unsigned long long)0)), double>::value), "");
1491     static_assert((std::is_same<decltype(trunc((double)0)), double>::value), "");
1492     static_assert((std::is_same<decltype(trunc((long double)0)), long double>::value), "");
1493     static_assert((std::is_same<decltype(truncf(0)), float>::value), "");
1494     static_assert((std::is_same<decltype(truncl(0)), long double>::value), "");
1495     static_assert((std::is_same<decltype(trunc(Ambiguous())), Ambiguous>::value), "");
1496     assert(trunc(1) == 1);
1497 }
1498 
main(int,char **)1499 int main(int, char**)
1500 {
1501     test_abs();
1502     test_acos();
1503     test_asin();
1504     test_atan();
1505     test_atan2();
1506     test_ceil();
1507     test_cos();
1508     test_cosh();
1509     test_exp();
1510     test_fabs();
1511     test_floor();
1512     test_fmod();
1513     test_frexp();
1514     test_ldexp();
1515     test_log();
1516     test_log10();
1517     test_modf();
1518     test_pow();
1519     test_sin();
1520     test_sinh();
1521     test_sqrt();
1522     test_tan();
1523     test_tanh();
1524     test_signbit();
1525     test_fpclassify();
1526     test_isfinite();
1527     test_isnormal();
1528     test_isgreater();
1529     test_isgreaterequal();
1530     test_isinf();
1531     test_isless();
1532     test_islessequal();
1533     test_islessgreater();
1534     test_isnan();
1535     test_isunordered();
1536     test_acosh();
1537     test_asinh();
1538     test_atanh();
1539     test_cbrt();
1540     test_copysign();
1541     test_erf();
1542     test_erfc();
1543     test_exp2();
1544     test_expm1();
1545     test_fdim();
1546     test_fma();
1547     test_fmax();
1548     test_fmin();
1549     test_hypot();
1550     test_ilogb();
1551     test_lgamma();
1552     test_llrint();
1553     test_llround();
1554     test_log1p();
1555     test_log2();
1556     test_logb();
1557     test_lrint();
1558     test_lround();
1559     test_nan();
1560     test_nearbyint();
1561     test_nextafter();
1562     test_nexttoward();
1563     test_remainder();
1564     test_remquo();
1565     test_rint();
1566     test_round();
1567     test_scalbln();
1568     test_scalbn();
1569     test_tgamma();
1570     test_trunc();
1571 
1572   return 0;
1573 }
1574