From adf0fff8eee76b646b7c1aa2172ea4c0f647b261 Mon Sep 17 00:00:00 2001
From: "David C. Lonie" <david.lonie@kitware.com>
Date: Fri, 4 Mar 2016 11:55:50 -0500
Subject: [PATCH] Use custom min/max in DataArray::GetRange on MSVC 2015.

Release builds on MSVC 2015 do not conform to the C++ standard. It
appears that an optimization is causing NaNs to be returned from the
calls, even when the NaN is passed as the second argument.
---
 Common/Core/vtkDataArrayPrivate.txx | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Common/Core/vtkDataArrayPrivate.txx b/Common/Core/vtkDataArrayPrivate.txx
index 907d491f659..f72860e1106 100644
--- a/Common/Core/vtkDataArrayPrivate.txx
+++ b/Common/Core/vtkDataArrayPrivate.txx
@@ -24,7 +24,7 @@
 
 namespace vtkDataArrayPrivate
 {
-#if defined(_MSC_VER) && ( _MSC_VER < 1900 )
+#if defined(_MSC_VER) && ( _MSC_VER < 2000 )
 namespace msvc
 {
 //----------------------------------------------------------------------------
@@ -36,6 +36,9 @@ namespace msvc
 // and also handles the cases where the right value may be a NaN properly.
 // All code using these methods should ensure that the "left" value is never
 // NaN.
+// We use _MSC_VER < 2000 instead of 1900 not due to performance issues, but
+// because MSVC 2015 (_MSC_VER=1900) doesn't handle NaNs properly in optimized
+// builds.
 template <class ValueType>
 ValueType max(const ValueType& left, const ValueType& right)
 {
@@ -52,7 +55,7 @@ ValueType min(const ValueType& left, const ValueType& right)
 
 namespace detail
 {
-#if defined(_MSC_VER) && ( _MSC_VER < 1900 )
+#if defined(_MSC_VER) && ( _MSC_VER < 2000 )
 using msvc::min;
 using msvc::max;
 #else
-- 
GitLab