[issue39277] _PyTime_FromDouble() fails to detect an integer overflow when converting a C double to a C int64_t

STINNER Victor report at bugs.python.org
Thu Jan 9 09:52:07 EST 2020


STINNER Victor <vstinner at python.org> added the comment:

It's a bug in _PyTime_FromDouble() which fails to detect the integer overflow when casting a C double to a C _PyTime_T (int64_t): bug in _Py_InIntegralTypeRange(_PyTime_t, d) where d is a C double.

On my Fedora 31, double is a 64-bit IEEE 754 float, _PyTime_t is int64_t (64-bit signed integer).

_PyTime_t maximum is 9223372036854775807. But casted as C double, it becomes 9223372036854775808:

>>> int(float(9223372036854775807))
9223372036854775808

----------
nosy: +benjamin.peterson

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39277>
_______________________________________


More information about the Python-bugs-list mailing list