diff --git a/include/pybind11/eigen.h b/include/pybind11/eigen.h index c0363827c..97b1d96b0 100644 --- a/include/pybind11/eigen.h +++ b/include/pybind11/eigen.h @@ -17,9 +17,23 @@ #include "numpy.h" +// The C4127 suppression was introduced for Eigen 3.4.0. In theory we could +// make it version specific, or even remove it later, but considering that +// 1. C4127 is generally far more distracting than useful for modern template code, and +// 2. we definitely want to ignore any MSVC warnings originating from Eigen code, +// it is probably best to keep this around indefinitely. +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable: 4127) // C4127: conditional expression is constant +#endif + #include #include +#if defined(_MSC_VER) +# pragma warning(pop) +#endif + // Eigen prior to 3.2.7 doesn't have proper move constructors--but worse, some classes get implicit // move constructors that break things. We could detect this an explicitly copy, but an extra copy // of matrices seems highly undesirable. @@ -559,7 +573,9 @@ struct type_caster::value>> { if (!values || !innerIndices || !outerIndices) return false; - value = Eigen::MappedSparseMatrix( + value = Eigen::MappedSparseMatrix( shape[0].cast(), shape[1].cast(), nnz, outerIndices.mutable_data(), innerIndices.mutable_data(), values.mutable_data()); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6ebcba9b6..d4e7b71e1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -174,9 +174,9 @@ set(PYBIND11_CROSS_MODULE_GIL_TESTS test_gil_scoped.py) set(PYBIND11_EIGEN_REPO "https://gitlab.com/libeigen/eigen.git" CACHE STRING "Eigen repository to use for tests") -# This hash is for 3.3.8, using a hash for security reasons +# This hash is for 3.4.0, using a hash for security reasons set(PYBIND11_EIGEN_VERSION - "dc252fbf00079ccab57948a164b1421703fe4361" + "929bc0e191d0927b1735b9a1ddc0e8b77e3a25ec" CACHE STRING "Eigen version to use for tests") # Check if Eigen is available; if not, remove from PYBIND11_TEST_FILES (but diff --git a/tests/test_eigen.cpp b/tests/test_eigen.cpp index ad572b2ad..d22a94a1a 100644 --- a/tests/test_eigen.cpp +++ b/tests/test_eigen.cpp @@ -13,6 +13,9 @@ #include #if defined(_MSC_VER) +#if _MSC_VER < 1910 // VS 2015's MSVC +# pragma warning(disable: 4127) // C4127: conditional expression is constant +#endif # pragma warning(disable: 4996) // C4996: std::unary_negation is deprecated #endif