Skip to content
Snippets Groups Projects
  • Tom Lane's avatar
    278b6059
    Improve handling of INT_MIN / -1 and related cases. · 278b6059
    Tom Lane authored
    Some platforms throw an exception for this division, rather than returning
    a necessarily-overflowed result.  Since we were testing for overflow after
    the fact, an exception isn't nice.  We can avoid the problem by treating
    division by -1 as negation.
    
    Add some regression tests so that we'll find out if any compilers try to
    optimize away the overflow check conditions.
    
    Back-patch of commit 1f7cb5c3.
    
    Per discussion with Xi Wang, though this is different from the patch he
    submitted.
    278b6059
    History
    Improve handling of INT_MIN / -1 and related cases.
    Tom Lane authored
    Some platforms throw an exception for this division, rather than returning
    a necessarily-overflowed result.  Since we were testing for overflow after
    the fact, an exception isn't nice.  We can avoid the problem by treating
    division by -1 as negation.
    
    Add some regression tests so that we'll find out if any compilers try to
    optimize away the overflow check conditions.
    
    Back-patch of commit 1f7cb5c3.
    
    Per discussion with Xi Wang, though this is different from the patch he
    submitted.