From 5207b3be6dbb54d5adeafa838fc2167bfddfadbb Mon Sep 17 00:00:00 2001 From: "Bobby R. Bruce" Date: Thu, 22 Aug 2024 06:47:04 -0700 Subject: [PATCH] ext,tests,misc: Suppress incorrect GCC 12 error in Pybind There is a compiler error with GCC 12 discussed here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115824 This Pybind code triggers the bug and was causing our compiler tests to fail. To fix gem5 compilation for gcc 12 these warnings/errors have been suppressed for this code. This is a copy and paste of: https://github.com/pybind/pybind11/pull/5355 Change-Id: I9344951ef00d121ea0b609f4faa13dfe09aabb3b --- ext/pybind11/include/pybind11/pybind11.h | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/ext/pybind11/include/pybind11/pybind11.h b/ext/pybind11/include/pybind11/pybind11.h index 6205effd61..51a0ab5e3a 100644 --- a/ext/pybind11/include/pybind11/pybind11.h +++ b/ext/pybind11/include/pybind11/pybind11.h @@ -1333,7 +1333,22 @@ protected: } else { internals.registered_types_cpp[tindex] = tinfo; } - internals.registered_types_py[(PyTypeObject *) m_ptr] = {tinfo}; + + + PYBIND11_WARNING_PUSH +#if defined(__GNUC__) && __GNUC__ == 12 + // When using GCC 12 the `array-bounds` and `stringop-overread` + // warnings are disabled as they trigger false positive warnings. + // + // This is a known GCC 12 issue and is discussed here: + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115824. This + // solution is based on advice given in this discussion but + // refactored with `PYBIND11_WARNING_DISABLE_GCC` MACRO. + PYBIND11_WARNING_DISABLE_GCC("-Warray-bounds") + PYBIND11_WARNING_DISABLE_GCC("-Wstringop-overread") +#endif + internals.registered_types_py[(PyTypeObject *) m_ptr] = {tinfo}; + PYBIND11_WARNING_POP if (rec.bases.size() > 1 || rec.multiple_inheritance) { mark_parents_nonsimple(tinfo->type);