diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index 1806583e6b..e56e2a0589 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1380,7 +1380,17 @@ class generic_type : public object { } else { internals.registered_types_cpp[tindex] = tinfo; } + + PYBIND11_WARNING_PUSH +#if defined(__GNUC__) && __GNUC__ == 12 + // When using GCC 12 these warnings are disabled as they trigger + // false positive warnings. Discussed here: + // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115824. + 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) {