8000 Don't use __builtin_mul_overflow · python/cpython@3a87da4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3a87da4

Browse files
committed
Don't use __builtin_mul_overflow
1 parent bd41fda commit 3a87da4

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Modules/_testexternalinspection.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -649,16 +649,13 @@ read_py_long(pid_t pid, _Py_DebugOffsets* offsets, uintptr_t address)
649649

650650
long value = 0;
651651

652+
// In theory this can overflow, but because of llvm/llvm-project#16778
653+
// we can't use __builtin_mul_overflow because it fails to link with
654+
// __muloti4 on aarch64. In practice this is fine because all we're
655+
// testing here are task numbers that would fit in a single byte.
652656
for (ssize_t i = 0; i < size; ++i) {
653-
long long factor;
654-
if (__builtin_mul_overflow(digits[i], (1UL << (ssize_t)(shift * i)),
655-
&factor)
656-
) {
657-
goto error;
658-
}
659-
if (__builtin_add_overflow(value, factor, &value)) {
660-
goto error;
661-
}
657+
long long factor = digits[i] * (1UL << (ssize_t)(shift * i));
658+
value += factor;
662659
}
663660
PyMem_RawFree(digits);
664661
if (negative) {

0 commit comments

Comments
 (0< 30A0 !-- -->)
0