• Sam Sneddon's avatar
    Fix several issues in overflow checks (GH-3591) · 92a0b75b
    Sam Sneddon authored
    * Fix #3588: Make existing overflow code safe
    Signed overflow is undefined behaviour in C and compilers can and do optimized on that basis.
    * Speed up our overflow impls
    Note this is primarily based on performance of compilers which do not
    support __builtin_add_overflow (i.e., not Clang >= 3.4 & gcc >= 5),
    mostly looking at several gcc 4 releases (used by older, supported,
    RHEL releases and Debian 8 "Jessie") and MSVC.
    * Use __builtin_XXX_overflow if available
    This is much quicker in general, as these all just then read the overflow flag from the status register.