mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
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:
parent
f701f98052
commit
b1554146c2
1 changed files with 2 additions and 1 deletions
|
|
@ -403,7 +403,8 @@ PyStackRef_IsTaggedInt(_PyStackRef i)
|
||||||
static inline _PyStackRef
|
static inline _PyStackRef
|
||||||
PyStackRef_TagInt(intptr_t i)
|
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) };
|
return (_PyStackRef){ .bits = ((((uintptr_t)i) << Py_TAGGED_SHIFT) | Py_INT_TAG) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue