Skip to content
forked from gem5/gem5

Commit 5207b3b

Browse files
committed
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: pybind/pybind11#5355 Change-Id: I9344951ef00d121ea0b609f4faa13dfe09aabb3b
1 parent 868e287 commit 5207b3b

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

ext/pybind11/include/pybind11/pybind11.h

+16-1
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,22 @@ class generic_type : public object {
13331333
} else {
13341334
internals.registered_types_cpp[tindex] = tinfo;
13351335
}
1336-
internals.registered_types_py[(PyTypeObject *) m_ptr] = {tinfo};
1336+
1337+
1338+
PYBIND11_WARNING_PUSH
1339+
#if defined(__GNUC__) && __GNUC__ == 12
1340+
// When using GCC 12 the `array-bounds` and `stringop-overread`
1341+
// warnings are disabled as they trigger false positive warnings.
1342+
//
1343+
// This is a known GCC 12 issue and is discussed here:
1344+
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115824. This
1345+
// solution is based on advice given in this discussion but
1346+
// refactored with `PYBIND11_WARNING_DISABLE_GCC` MACRO.
1347+
PYBIND11_WARNING_DISABLE_GCC("-Warray-bounds")
1348+
PYBIND11_WARNING_DISABLE_GCC("-Wstringop-overread")
1349+
#endif
1350+
internals.registered_types_py[(PyTypeObject *) m_ptr] = {tinfo};
1351+
PYBIND11_WARNING_POP
13371352

13381353
if (rec.bases.size() > 1 || rec.multiple_inheritance) {
13391354
mark_parents_nonsimple(tinfo->type);

0 commit comments

Comments
 (0)