From 9a37aca9fc3647d300159a0480f3c2655b33711f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20S=C3=A1nchez?= Date: Thu, 15 Jan 2026 19:04:53 +0000 Subject: [PATCH] Fix assignment size assertion for EIGEN_NO_AUTOMATIC_RESIZING. libeigen/eigen!2108 Closes #3018 --- Eigen/src/Core/AssignEvaluator.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Eigen/src/Core/AssignEvaluator.h b/Eigen/src/Core/AssignEvaluator.h index a467575f7..e931612d2 100644 --- a/Eigen/src/Core/AssignEvaluator.h +++ b/Eigen/src/Core/AssignEvaluator.h @@ -804,8 +804,17 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE constexpr void resize_if_allowed(DstXprTyp const internal::assign_op& /*func*/) { Index dstRows = src.rows(); Index dstCols = src.cols(); - if (((dst.rows() != dstRows) || (dst.cols() != dstCols))) dst.resize(dstRows, dstCols); - eigen_assert(dst.rows() == dstRows && dst.cols() == dstCols); + if (((dst.rows() != dstRows) || (dst.cols() != dstCols))) { +#ifdef EIGEN_NO_AUTOMATIC_RESIZING + eigen_assert( + (dst.size() == 0 || (DstXprType::IsVectorAtCompileTime ? (dst.size() == src.size()) + : (dst.rows() == dstRows && dst.cols() == dstCols))) && + "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined"); +#else + dst.resize(dstRows, dstCols); + eigen_assert(dst.rows() == dstRows && dst.cols() == dstCols); +#endif + } } template