Hi,
thanks for Clojure! Here's my first contribution (CA filled out and  
will arrive next week):

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 is created against trunk r1159. Same examples after  
applying it:

user=> (- -2147483648)
2147483648

user=> (- -1 -2147483648)
2147483647


/Olov Lassus


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
To unsubscribe from this group, send email to 
clojure+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Attachment: detect_negate_overflow.patch
Description: Binary data


Reply via email to