TestMath test failed in case std::isinf() returns -1 for -inf value
This issue was created automatically from an original Mantis Issue. Further discussion may take place here.
Hello,
My output from testing: ... Testing comparison of vtkMath::NegInf() to non-finite values.
- IsNan test.
- IsInf test. -inf failed the IsInf test.
Actually, "man isinf" says: CONFORMING TO C99, POSIX.1.
For isinf(), the standards merely say that the return value is non-zero if and only if the argument has an infinite value.
NOTES In glibc 2.01 and earlier, isinf() returns a non-zero value (actually: 1) if x is positive infinity or negative infinity. (This is all that C99 requires.)
Code with issue is (vtk/Common/Core/vtkMath.h): inline int vtkMath::IsInf(double x) { #if defined(VTK_HAS_STD_ISINF) return std::isinf(x); #else return (isinf(x) != 0); // Force conversion to bool #endif }
Test failed due to if statement (vtk/Common/Core/Testing/Cxx/TestMath.cxx): vtkMath::IsInf(value) != static_cast(inftest)
Proposed patch is (vtk/Common/Core/vtkMath.h): @@ -1248,7 +1248,7 @@ inline int vtkMath::IsInf(double x) { #if defined(VTK_HAS_STD_ISINF)
- return std::isinf(x);
- return (std::isinf(x) != 0); // Force conversion to bool #else return (isinf(x) != 0); // Force conversion to bool #endif