Clojure

unchecked int math inconsistency with Java

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: Release 1.3
  • Component/s: None
  • Labels:
    None
  • Patch:
    Code and Test
  • Approval:
    Ok

Description

Clojure 1.3.0-alpha4
user=> (-' 0 -9223372036854775808)
-9223372036854775808

Activity

Hide
Colin Jones added a comment -

This looks like a case where, in minusP, negateP was properly promoting the negation of -9223372036854775808 (Long/MIN_VALUE) to a BigInt, but that promotion didn't propagate to addP. The Ops that got used in addP was ops(-9223372036854775808), not ops(9223372036854775808N).

The attached patch makes sure the BigInt contamination goes all the way through, and adds a few tests verifying the correct behavior.

Show
Colin Jones added a comment - This looks like a case where, in minusP, negateP was properly promoting the negation of -9223372036854775808 (Long/MIN_VALUE) to a BigInt, but that promotion didn't propagate to addP. The Ops that got used in addP was ops(-9223372036854775808), not ops(9223372036854775808N). The attached patch makes sure the BigInt contamination goes all the way through, and adds a few tests verifying the correct behavior.

People

Vote (0)
Watch (1)

Dates

  • Created:
    Updated:
    Resolved: