You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
<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.
The text was updated successfully, but these errors were encountered:
This is (partially) fixed by #4537. The remain issue, additional overloads missing in <math.h> in C++ mode, is out of the scope of this repo. I opened DevCom-10294165 but it was recently closed as Lower Priority...
Yep, @frederick-vs-ja is correct, this is fixed for <cmath>. #4537 shipped in VS 2022 17.11 Preview 2 which is available now. (Compiler Explorer got actual MSVC compilation and execution back 🎉 but is currently limited to 17.8).
Describe the bug
std::isnan
fails 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::isnan
can 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.The text was updated successfully, but these errors were encountered: