Skip to content

Commit 31d7c87

Browse files
daizhiruirwgk
andauthored
Remove some maybe-uninitialized warnings (#5516)
* 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]>
1 parent d2e7e8c commit 31d7c87

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

include/pybind11/eigen/matrix.h

+3
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,11 @@ struct type_caster<Type, enable_if_t<is_eigen_dense_plain<Type>::value>> {
316316
return false;
317317
}
318318

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

0 commit comments

Comments
 (0)