Re: [eigen] Eigen warning. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/eigen Archives
]
- To: eigen@xxxxxxxxxxxxxxxxxxx
- Subject: Re: [eigen] Eigen warning.
- From: Sergiu Dotenco <sergiu.dotenco@xxxxxxxxx>
- Date: Thu, 28 Jan 2016 00:05:42 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-type; bh=oduitZdBLbevU+ZTlDmZlVKLOOnt/oFviEe1LzR1kGs=; b=WIq665rzAzSf7V+StyO8sBkUXCGW2dXOQv8VfGE9kAt70hCi9DgudDsvLM8Sv4HoCE 6iNC8/RNEIAeX8V+uesaupIG37ckGn/+VxB8uMGjDHsGYN+WX4gyIbsbbA3PR8Zjep6j vtLO5/X/FdNUbiNzrbnty1VFKnVp94j11Tio4QmLaGsyclPuWJ7gfhe6N8bEbWh8MS8t bYR3RN726kFDUww26nRpbPreODVzI6TQkmdx9Sa1v+63hvVsFi4CsV8kp88GlRqd7uVP VWX44FfdC6/1VX9vPQpD4TrKPqn3VKc/BRKH2FAVF27+RWB1JQlah3ypL8Autf3Ew8yh nbJQ==
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>