Skip to content

Commit

Permalink
Remove some maybe-uninitialized warnings (#5516)
Browse files Browse the repository at this point in the history
* 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".

* Revert "Remove some maybe-uninitialized warnings"

This reverts commit 7d5a9b4.

* Suppress `-Wmaybe-uninitialized` warning

Reproducer: #5516 (comment)

---------

Co-authored-by: Ralf W. Grosse-Kunstleve <[email protected]>
  • Loading branch information
daizhirui and rwgk authored Feb 8, 2025
1 parent d2e7e8c commit 31d7c87
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions include/pybind11/eigen/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,11 @@ struct type_caster<Type, enable_if_t<is_eigen_dense_plain<Type>::value>> {
return false;
}

PYBIND11_WARNING_PUSH
PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // See PR #5516
// Allocate the new type, then build a numpy reference into it
value = Type(fits.rows, fits.cols);
PYBIND11_WARNING_POP
auto ref = reinterpret_steal<array>(eigen_ref_array<props>(value));
if (dims == 1) {
ref = ref.squeeze();
Expand Down

0 comments on commit 31d7c87

Please sign in to comment.