Completed
Details
Assignee
UnassignedUnassignedReporter
Andy FingerhutAndy FingerhutLabels
Approval
OkPatch
Code and TestPriority
MajorAffects versions
Fix versions
Details
Details
Assignee
Unassigned
UnassignedReporter
Andy Fingerhut
Andy FingerhutLabels
Approval
Ok
Patch
Code and Test
Priority

Affects versions
Fix versions
Created October 26, 2015 at 7:11 AM
Updated September 14, 2018 at 10:21 PM
Resolved September 14, 2018 at 10:21 PM
The behavior of unchecked-* functions such as unchecked-add, unchecked-subtract, and unchecked-multiply give different results for primitive longs (expected) and boxed longs (can get overflow exceptions). For example:
user=> *clojure-version* {:major 1, :minor 7, :incremental 0, :qualifier nil} user=> (doc unchecked-multiply) ------------------------- clojure.core/unchecked-multiply ([x y]) Returns the product of x and y, both long. Note - uses a primitive operator subject to overflow. nil user=> (unchecked-multiply 2432902008176640000 21) -4249290049419214848 user=> (unchecked-multiply 2432902008176640000 (Long. 21)) ArithmeticException integer overflow clojure.lang.Numbers.throwIntOverflow (Numbers.java:1501)
Normally no one would use explicit boxed Long arguments like in the example above, but these can easily occur, unintentionally, if the arguments to the unchecked functions are not explicitly type hinted as primitive long values.
Approach: clj-1832.patch
Screened: Alex Miller