https://github.com/python/cpython/commit/b1554146c29182803d1df23d6367c07a429d21ba
commit: b1554146c29182803d1df23d6367c07a429d21ba
branch: main
author: Dino Viehland <[email protected]>
committer: DinoV <[email protected]>
date: 2025-11-01T12:23:58-04:00
summary:
gh-140868: Don't rely on undefined left shift behavior in assert (#140869)
Don't rely on undefined left shift behavior in assert
files:
M Include/internal/pycore_stackref.h
diff --git a/Include/internal/pycore_stackref.h
b/Include/internal/pycore_stackref.h
index 94fcb1d8aee52b..15a703a08204da 100644
--- a/Include/internal/pycore_stackref.h
+++ b/Include/internal/pycore_stackref.h
@@ -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) };
}
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]