From 801a9ee6903e3e80b9cba5d03e0b68335d4f9828 Mon Sep 17 00:00:00 2001 From: Rasmus Munk Larsen <4643818-rmlarsen1@users.noreply.gitlab.com> Date: Sun, 29 Mar 2026 21:05:49 -0700 Subject: [PATCH] Fix ~1,460 MSVC warnings from generic code instantiated with bool libeigen/eigen!2364 Co-authored-by: Rasmus Munk Larsen --- Eigen/src/Core/RealView.h | 2 +- Eigen/src/Core/products/GeneralBlockPanelKernel.h | 11 +++++++++++ Eigen/src/Core/products/GeneralMatrixVector.h | 11 +++++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/Eigen/src/Core/RealView.h b/Eigen/src/Core/RealView.h index 3be5556a8..59cd6d54e 100644 --- a/Eigen/src/Core/RealView.h +++ b/Eigen/src/Core/RealView.h @@ -72,7 +72,7 @@ struct evaluator> : private evaluator { static constexpr int CoeffReadCost = BaseEvaluator::CoeffReadCost; static constexpr int Alignment = BaseEvaluator::Alignment; static constexpr bool IsRowMajor = ExpressionTraits::IsRowMajor; - static constexpr bool DirectAccess = Flags & DirectAccessBit; + static constexpr bool DirectAccess = (Flags & DirectAccessBit) != 0; using ComplexCoeffReturnType = std::conditional_t; using CoeffReturnType = std::conditional_t; diff --git a/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/Eigen/src/Core/products/GeneralBlockPanelKernel.h index 7314b2931..49dc85406 100644 --- a/Eigen/src/Core/products/GeneralBlockPanelKernel.h +++ b/Eigen/src/Core/products/GeneralBlockPanelKernel.h @@ -13,6 +13,13 @@ // IWYU pragma: private #include "../InternalHeaderCheck.h" +// C4804: unsafe use of type 'bool' in operation. Unavoidable in generic code +// instantiated with bool scalars (e.g. += and * on bool). +#if EIGEN_COMP_MSVC +#pragma warning(push) +#pragma warning(disable : 4804) +#endif + namespace Eigen { namespace internal { @@ -2396,4 +2403,8 @@ inline void setCpuCacheSizes(std::ptrdiff_t l1, std::ptrdiff_t l2, std::ptrdiff_ } // end namespace Eigen +#if EIGEN_COMP_MSVC +#pragma warning(pop) +#endif + #endif // EIGEN_GENERAL_BLOCK_PANEL_H diff --git a/Eigen/src/Core/products/GeneralMatrixVector.h b/Eigen/src/Core/products/GeneralMatrixVector.h index 40694f2e6..5f6c3958d 100644 --- a/Eigen/src/Core/products/GeneralMatrixVector.h +++ b/Eigen/src/Core/products/GeneralMatrixVector.h @@ -13,6 +13,13 @@ // IWYU pragma: private #include "../InternalHeaderCheck.h" +// C4804: unsafe use of type 'bool' in operation. Unavoidable in generic code +// instantiated with bool scalars (e.g. += and * on bool). +#if EIGEN_COMP_MSVC +#pragma warning(push) +#pragma warning(disable : 4804) +#endif + namespace Eigen { namespace internal { @@ -672,4 +679,8 @@ general_matrix_vector_product