gh-91320: Fix more old-style cast warnings in C++ (#92247) · python/cpython@ff3e9cd · GitHub
Skip to content

Commit ff3e9cd

Browse files
authored
gh-91320: Fix more old-style cast warnings in C++ (#92247)
Use _Py_CAST(), _Py_STATIC_CAST() and _PyASCIIObject_CAST() in static inline functions to fix C++ compiler warnings: "use of old-style cast" (clang -Wold-style-cast). test_cppext now builds the C++ test extension with -Wold-style-cast.
1 parent b270b82 commit ff3e9cd

3 files changed

Lines changed: 19 additions & 16 deletions

File tree

Include/cpython/unicodeobject.h

Lines changed: 16 additions & 15 deletions

Include/cpython/weakrefobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PyAPI_FUNC(void) _PyWeakref_ClearRef(PyWeakReference *self);
3838

3939
static inline PyObject* PyWeakref_GET_OBJECT(PyObject *ref_obj) {
4040
assert(PyWeakref_Check(ref_obj));
41-
PyWeakReference *ref = (PyWeakReference *)ref_obj;
41+
PyWeakReference *ref = _Py_CAST(PyWeakReference*, ref_obj);
4242
PyObject *obj = ref->wr_object;
4343
// Explanation for the Py_REFCNT() check: when a weakref's target is part
4444
// of a long chain of deallocations which triggers the trashcan mechanism,

Lib/test/test_cppext.py

Lines changed: 2 additions & 0 deletions

0 commit comments

Comments
 (0)