Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 40632b1

Browse filesBrowse files
authored
gh-122974: Suppress GCC array bound warnings in free-threaded build (#123071)
GCC 11 and newer warn about the access to `unique_id` in non-debug builds due to inlining the call on static non-heap types.
1 parent 44e4583 commit 40632b1
Copy full SHA for 40632b1

File tree

1 file changed

+12
-0
lines changed
Filter options

1 file changed

+12
-0
lines changed

‎Include/internal/pycore_object.h

Copy file name to clipboardExpand all lines: Include/internal/pycore_object.h
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff 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

324336
static inline void

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.