gh-140868: Don't rely on undefined left shift behavior in assert (#140869)

Don't rely on undefined left shift behavior in assert
This commit is contained in:
Dino Viehland 2025-11-01 12:23:58 -04:00 committed by GitHub
parent f701f98052
commit b1554146c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -403,7 +403,8 @@ PyStackRef_IsTaggedInt(_PyStackRef i)
static inline _PyStackRef
PyStackRef_TagInt(intptr_t i)
{
assert(Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, (i << Py_TAGGED_SHIFT), Py_TAGGED_SHIFT) == i);
assert(Py_ARITHMETIC_RIGHT_SHIFT(intptr_t, (intptr_t)(((uintptr_t)i) << Py_TAGGED_SHIFT),
Py_TAGGED_SHIFT) == i);
return (_PyStackRef){ .bits = ((((uintptr_t)i) << Py_TAGGED_SHIFT) | Py_INT_TAG) };
}