Message 328688 - Python tracker

Message328688

Author izbyshev
Recipients berker.peksag, izbyshev, pitrou, serhiy.storchaka
Date 2018-10-28.13:40:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1540734023.23.0.788709270274.issue35091@psf.upfronthosting.co.za>
In-reply-to
Content
gallop_left() and gallop_right() functions explicitly rely on overflowing behavior of Py_ssize_t (https://github.com/python/cpython/blob/6015cc50bc38b9e920ce4986ee10658eaa14f561/Objects/listobject.c#L1361):

    ofs = (ofs << 1) + 1;
    if (ofs <= 0)                   /* int overflow */
        ofs = maxofs;

Signed integer overflow is undefined in C, and the above is guaranteed to work only if compiler-specific workarounds are applied, such as GCC's -fwrapv (that is what CPython does). Without such workarounds the compiler would be free to remove the if statement.
History
Date User Action Args
2018-10-28 13:40:23izbyshevsetrecipients: + izbyshev, pitrou, berker.peksag, serhiy.storchaka
2018-10-28 13:40:23izbyshevsetmessageid: <1540734023.23.0.788709270274.issue35091@psf.upfronthosting.co.za>
2018-10-28 13:40:23izbyshevlinkissue35091 messages
2018-10-28 13:40:23izbyshevcreate