File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed
Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -301,6 +301,14 @@ _Py_INCREF_TYPE(PyTypeObject *type)
301301 return ;
302302 }
303303
304+ // gh-122974: GCC 11 warns about the access to PyHeapTypeObject fields when
305+ // _Py_INCREF_TYPE() is called on a statically allocated type. The
306+ // _PyType_HasFeature check above ensures that the type is a heap type.
307+ #if defined(__GNUC__ ) && __GNUC__ >= 11
308+ # pragma GCC diagnostic push
309+ # pragma GCC diagnostic ignored "-Warray-bounds"
310+ #endif
311+
304312 _PyThreadStateImpl * tstate = (_PyThreadStateImpl * )_PyThreadState_GET ();
305313 PyHeapTypeObject * ht = (PyHeapTypeObject * )type ;
306314
@@ -319,6 +327,10 @@ _Py_INCREF_TYPE(PyTypeObject *type)
319327 // It handles the unique_id=-1 case to keep the inlinable function smaller.
320328 _PyType_IncrefSlow (ht );
321329 }
330+
331+ #if defined(__GNUC__ ) && __GNUC__ >= 11
332+ # pragma GCC diagnostic pop
333+ #endif
322334}
323335
324336static inline void
You can’t perform that action at this time.
0 commit comments