gh-124064: Fix -Wconversion warnings in pycore_{long,object}.h (#124177)

Change also the fix for pycore_gc.h and pycore_stackref.h:
declare constants as uintptr_t, rather than casting constants.
This commit is contained in:
Victor Stinner 2024-09-17 17:35:40 +02:00 committed by GitHub
parent ab80c6b402
commit ec08aa1fe4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 19 additions and 24 deletions

View file

@ -56,8 +56,8 @@ typedef union _PyStackRef {
#define Py_TAG_DEFERRED (1)
#define Py_TAG_PTR (0)
#define Py_TAG_BITS (1)
#define Py_TAG_PTR ((uintptr_t)0)
#define Py_TAG_BITS ((uintptr_t)1)
#ifdef Py_GIL_DISABLED
static const _PyStackRef PyStackRef_NULL = { .bits = 0 | Py_TAG_DEFERRED};
@ -98,7 +98,7 @@ typedef union _PyStackRef {
static inline PyObject *
PyStackRef_AsPyObjectBorrow(_PyStackRef stackref)
{
PyObject *cleared = ((PyObject *)((stackref).bits & (~(uintptr_t)Py_TAG_BITS)));
PyObject *cleared = ((PyObject *)((stackref).bits & (~Py_TAG_BITS)));
return cleared;
}
#else