Skip to content

Commit

Permalink
Remove some maybe-uninitialized warnings
Browse files Browse the repository at this point in the history
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".
  • Loading branch information
daizhirui authored Feb 6, 2025
1 parent d2e7e8c commit 7d5a9b4
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/pybind11/eigen/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ struct type_caster<Type, enable_if_t<is_eigen_dense_plain<Type>::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<array>(eigen_ref_array<props>(value));
if (dims == 1) {
ref = ref.squeeze();
Expand Down

0 comments on commit 7d5a9b4

Please sign in to comment.