Describe the bug
std::isnan fails to compile when passed an argument of integer type.
Command-line test case
#include <cmath>
bool b = std::isnan(0);
results in:
/opt/compiler-explorer/windows/10.0.10240.0/ucrt/math.h(403): error C2668: 'fpclassify': ambiguous call to overloaded function
/opt/compiler-explorer/windows/10.0.10240.0/ucrt/math.h(288): note: could be 'int fpclassify(long double) noexcept'
/opt/compiler-explorer/windows/10.0.10240.0/ucrt/math.h(283): note: or 'int fpclassify(double) noexcept'
/opt/compiler-explorer/windows/10.0.10240.0/ucrt/math.h(278): note: or 'int fpclassify(float) noexcept'
/opt/compiler-explorer/windows/10.0.10240.0/ucrt/math.h(403): note: while trying to match the argument list '(int)'
<source>(3): note: see reference to function template instantiation 'bool isnan<int>(_Ty) noexcept' being compiled
with
[
_Ty=int
]
Compiler returned: 2
Live on compiler explorer
Expected behavior
<cmath> is required to provide sufficient additional overloads such that std::isnan can be applied to integer types, with the behavior that the integer value is implicitly converted to double (so that std::isnan(0) returns false). This doesn't appear to work under MSVC.
Describe the bug
std::isnanfails to compile when passed an argument of integer type.Command-line test case
results in:
Live on compiler explorer
Expected behavior
<cmath>is required to provide sufficient additional overloads such thatstd::isnancan be applied to integer types, with the behavior that the integer value is implicitly converted todouble(so thatstd::isnan(0)returns false). This doesn't appear to work under MSVC.