diff options
author | Gael Guennebaud <g.gael@free.fr> | 2018-11-21 15:53:37 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2018-11-21 15:53:37 +0100 |
commit | 4b2cebade8512abe05e94fd08ef901d818d8912b (patch) | |
tree | e64d2a69f71d05a3e4452143f34cf1879e68f0a7 | |
parent | 0ec8afde57f6b004dbe74116604081a191a52d56 (diff) |
Workaround weird MSVC bug
-rw-r--r-- | Eigen/src/SVD/SVDBase.h | 4 | ||||
-rw-r--r-- | test/jacobi.cpp | 15 |
2 files changed, 18 insertions, 1 deletions
diff --git a/Eigen/src/SVD/SVDBase.h b/Eigen/src/SVD/SVDBase.h index 429414797..1aede5ab0 100644 --- a/Eigen/src/SVD/SVDBase.h +++ b/Eigen/src/SVD/SVDBase.h @@ -180,8 +180,10 @@ public: RealScalar threshold() const { eigen_assert(m_isInitialized || m_usePrescribedThreshold); + // this temporary is needed to workaround a MSVC issue + Index diagSize = (std::max<Index>)(1,m_diagSize); return m_usePrescribedThreshold ? m_prescribedThreshold - : (std::max<Index>)(1,m_diagSize)*NumTraits<Scalar>::epsilon(); + : diagSize*NumTraits<Scalar>::epsilon(); } /** \returns true if \a U (full or thin) is asked for in this SVD decomposition */ diff --git a/test/jacobi.cpp b/test/jacobi.cpp index 5604797f5..27b6e46d9 100644 --- a/test/jacobi.cpp +++ b/test/jacobi.cpp @@ -57,6 +57,19 @@ void jacobi(const MatrixType& m = MatrixType()) } } +namespace Foo { +class Bar {}; +bool operator<(const Bar&, const Bar&) { return true; } +} +// regression test for a very strange MSVC issue for which simply +// including SVDBase.h messes up with std::max and custom scalar type +void msvc_workaround() +{ + const Foo::Bar a; + const Foo::Bar b; + std::max EIGEN_NOT_A_MACRO (a,b); +} + EIGEN_DECLARE_TEST(jacobi) { for(int i = 0; i < g_repeat; i++) { @@ -77,4 +90,6 @@ EIGEN_DECLARE_TEST(jacobi) TEST_SET_BUT_UNUSED_VARIABLE(r); TEST_SET_BUT_UNUSED_VARIABLE(c); } + + msvc_workaround(); } |