From 31d7c870cfbc964e6305b09332e2bcf65bdde93e Mon Sep 17 00:00:00 2001 From: daizhirui Date: Sat, 8 Feb 2025 10:43:25 -0800 Subject: [PATCH 1/2] 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 7d5a9b41aaf6878f9ff27aa0fb68c6de4a409a01. * Suppress `-Wmaybe-uninitialized` warning Reproducer: https://github.com/pybind/pybind11/pull/5516#issuecomment-2645846295 --------- Co-authored-by: Ralf W. Grosse-Kunstleve --- include/pybind11/eigen/matrix.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/pybind11/eigen/matrix.h b/include/pybind11/eigen/matrix.h index 5cf1f0a2a..d2999d61b 100644 --- a/include/pybind11/eigen/matrix.h +++ b/include/pybind11/eigen/matrix.h @@ -316,8 +316,11 @@ struct type_caster::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(eigen_ref_array(value)); if (dims == 1) { ref = ref.squeeze(); From c316cf36204e447856b44092a0e4616705e62393 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 12 Feb 2025 15:05:58 -0800 Subject: [PATCH 2/2] Make PYBIND11_INTERNALS_VERSION 6 the default on all platforms. (#5512) --- include/pybind11/detail/internals.h | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h index 5fcaf9b9c..13f82d030 100644 --- a/include/pybind11/detail/internals.h +++ b/include/pybind11/detail/internals.h @@ -37,22 +37,14 @@ /// further ABI-incompatible changes may be made before the ABI is officially /// changed to the new version. #ifndef PYBIND11_INTERNALS_VERSION -# if PY_VERSION_HEX >= 0x030C0000 || defined(_MSC_VER) -// Version bump for Python 3.12+, before first 3.12 beta release. -// Version bump for MSVC piggy-backed on PR #4779. See comments there. -# ifdef Py_GIL_DISABLED -# define PYBIND11_INTERNALS_VERSION 6 -# else -# define PYBIND11_INTERNALS_VERSION 5 -# endif -# else -# define PYBIND11_INTERNALS_VERSION 4 -# endif +# define PYBIND11_INTERNALS_VERSION 6 #endif // This requirement is mainly to reduce the support burden (see PR #4570). static_assert(PY_VERSION_HEX < 0x030C0000 || PYBIND11_INTERNALS_VERSION >= 5, "pybind11 ABI version 5 is the minimum for Python 3.12+"); +static_assert(PYBIND11_INTERNALS_VERSION >= 4, + "pybind11 ABI version 4 is the minimum for all platforms."); PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)