Reported by olov.lassus, Jan 02, 2009
Negating Integer.MIN_VALUE overflows but should return a BigInteger.
It also affects binary subtraction since Clojure implements it using
negation and addition. The overflow occurs silently without throwing
an exception.
These examples trigger the flaw:
user=> (- -2147483648)
-2147483648
user=> (- -1 -2147483648)
-2147483649
The attached patch apply cleanly against trunk r1195. Same examples after
applying it:
user=> (- -2147483648)
2147483648
user=> (- -1 -2147483648)
2147483647
detect_negate_overflow.patch
507 bytes Download
Comment 1 by richhickey, Jan 07, 2009
fixed in svn 1203
Status: Fixed
Converted from http://www.assembla.com/spaces/clojure/tickets/32
Attachments:
detect_negate_overflow.patch - https://www.assembla.com/spaces/clojure/documents/aC6MlEw3ir3Qr1eJe5aVNr/download/aC6MlEw3ir3Qr1eJe5aVNr