From 7d5a9b41aaf6878f9ff27aa0fb68c6de4a409a01 Mon Sep 17 00:00:00 2001 From: daizhirui Date: Thu, 6 Feb 2025 00:56:52 -0800 Subject: [PATCH] Remove some maybe-uninitialized warnings In the Eigen matrix type_caster, resize the matrix instead of assigning with a new one when the matrix size needs to be adjusted. This can remove lots of compiling warnings about "maybe-uninitialized". --- include/pybind11/eigen/matrix.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pybind11/eigen/matrix.h b/include/pybind11/eigen/matrix.h index 5cf1f0a2a..a62c542d5 100644 --- a/include/pybind11/eigen/matrix.h +++ b/include/pybind11/eigen/matrix.h @@ -317,7 +317,7 @@ struct type_caster::value>> { } // Allocate the new type, then build a numpy reference into it - value = Type(fits.rows, fits.cols); + value.resize(fits.rows, fits.cols); auto ref = reinterpret_steal(eigen_ref_array(value)); if (dims == 1) { ref = ref.squeeze();