I have been given the task of installing a simulation, but I keep running into error codes. I was able to resolve most of them, but there is one I am not sure how to tackle.
The error code is C2668
, and its description is:
"fpclassify': ambiguous call to overloaded function
Project is "Run Simulation" and File is corecrt_math.h
on line 415.
Honestly, I'm not sure if any of the information I have given is of any use, and I'm not sure what information to provide. Maybe it would be better if you could ask me some questions and I can answer them to the best of my ability?
I have included a screenshot of my Visual Studio 19:
(Click image to enlarge)
Reproducible example (demo)
#include <cmath>
int main() {
std::isnan(1);
}
Expected outcome: That it compiles.
You probably fed std::fpclassify
an integer somehow. Visual Studio has an issue with the integer overloads for the <cmath>
functions that manifests itself like in your case instead of casting the integer to a double
in accordance with:
[…] if any argument of arithmetic type corresponding to a
double
parameter has typedouble
or an integer type, then all arguments of arithmetic type corresponding todouble
parameters are effectively cast todouble
.
I wrote an error report for std::signbit
but it's the same for all <cmath>
functions that I've tested and std::fpclassify
is one of them - and it's used internally by many other cmath
functions.
Line 415 in corecrt_math.h
is within the isnan
function which calls fpclassify
internally.
Steps to fix the problem:
see reference to function template instantiation 'bool isnan<int>(_Ty) noexcept' being compiled
or similar. The <int>
part may be any integer type.isnan
that is made with an integer.isnan(
integer
)
call with isnan(static_cast<double>(
integer
))
.cmath
functions causing problems.Note: Using isnan
with integers is pointless. isnan(
integer
)
will always return false
so a compiler with optimization turned on should replace the whole call with false
.