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
This commit is contained in:
Bobby R. Bruce
2024-08-22 06:47:04 -07:00
parent 868e287e71
commit 5207b3be6d

View File

@@ -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);