Skip to content

Commit 7d5a9b4

Browse files
authored
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".
1 parent d2e7e8c commit 7d5a9b4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/pybind11/eigen/matrix.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ struct type_caster<Type, enable_if_t<is_eigen_dense_plain<Type>::value>> {
317317
}
318318

319319
// Allocate the new type, then build a numpy reference into it
320-
value = Type(fits.rows, fits.cols);
320+
value.resize(fits.rows, fits.cols);
321321
auto ref = reinterpret_steal<array>(eigen_ref_array<props>(value));
322322
if (dims == 1) {
323323
ref = ref.squeeze();

0 commit comments

Comments
 (0)