Re: [eigen] Eigen warning.

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On 1/27/2016 10:32 PM, Gael Guennebaud wrote:
> 
> On Wed, Jan 27, 2016 at 7:50 PM, Billy Araujo <billyaraujo@xxxxxxxxx
> <mailto:billyaraujo@xxxxxxxxx>> wrote:
> 
>     warning C4800: '__int64' : forcing value to bool 'true' or 'false'
>     (performance warning)
> 
> 
> and what can we do to workaround this stupid warning? Replace the enum
> by a static bool ?

Unfortunately, this is not what causes the problem. It's the static test
function that actually expects a bool but receives an __int64. Hence the
warning. There are also warnings caused by _isnan usage.

I've attached patches that fix both problems. At least they seem to work
for me.
# HG changeset patch
# User Sergiu Dotenco <sergiu.dotenco@xxxxxxxxx>
# Date 1453935734 -3600
#      Thu Jan 28 00:02:14 2016 +0100
# Node ID bd62ffa74b2f13f8d2053e236528fc12e4a3b5c8
# Parent  10f46efdcf3d8424d580bcf709b7d054c2121cc5
silence MSVC's _isnan related warnings

diff --git a/Eigen/src/Core/MathFunctions.h b/Eigen/src/Core/MathFunctions.h
--- a/Eigen/src/Core/MathFunctions.h
+++ b/Eigen/src/Core/MathFunctions.h
@@ -748,9 +748,9 @@
 }
 
 //MSVC defines a _isnan builtin function, but for double only
-EIGEN_DEVICE_FUNC inline bool isnan_impl(const long double& x) { return _isnan(x); }
-EIGEN_DEVICE_FUNC inline bool isnan_impl(const double& x)      { return _isnan(x); }
-EIGEN_DEVICE_FUNC inline bool isnan_impl(const float& x)       { return _isnan(x); }
+EIGEN_DEVICE_FUNC inline bool isnan_impl(const long double& x) { return !!_isnan(x); }
+EIGEN_DEVICE_FUNC inline bool isnan_impl(const double& x)      { return !!_isnan(x); }
+EIGEN_DEVICE_FUNC inline bool isnan_impl(const float& x)       { return !!_isnan(x); }
 
 EIGEN_DEVICE_FUNC inline bool isinf_impl(const long double& x) { return isinf_msvc_helper(x); }
 EIGEN_DEVICE_FUNC inline bool isinf_impl(const double& x)      { return isinf_msvc_helper(x); }
# HG changeset patch
# User Sergiu Dotenco <sergiu.dotenco@xxxxxxxxx>
# Date 1453935734 -3600
#      Thu Jan 28 00:02:14 2016 +0100
# Node ID b3f80ead7563aef52b3c9358965d15260a90a83b
# Parent  bd62ffa74b2f13f8d2053e236528fc12e4a3b5c8
silence MSVC int to bool conversion performance warning

diff --git a/Eigen/src/Core/util/Meta.h b/Eigen/src/Core/util/Meta.h
--- a/Eigen/src/Core/util/Meta.h
+++ b/Eigen/src/Core/util/Meta.h
@@ -115,7 +115,14 @@
 
 public:
   static From ms_from;
+#ifdef _MSC_VER
+#pragma warning(push)
+#pragma warning(disable: 4800)
+#endif // defined(_MSC_VER)
   enum { value = sizeof(test(ms_from, 0))==sizeof(yes) };
+#ifdef _MSC_VER
+#pragma warning(pop)
+#endif // defined(_MSC_VER)
 };
 
 template<typename From, typename To>


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/