Skip to content

Commit

Permalink
ext,tests,misc: Suppress incorrect GCC 12 error in Pybind
Browse files Browse the repository at this point in the history
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:
pybind/pybind11#5355

Change-Id: I9344951ef00d121ea0b609f4faa13dfe09aabb3b
  • Loading branch information
BobbyRBruce authored and nkrim committed Sep 11, 2024
1 parent 5c2725e commit f1fb4cf
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion ext/pybind11/include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,22 @@ class generic_type : public object {
} 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);
Expand Down

0 comments on commit f1fb4cf

Please sign in to comment.