From 7ffd3e9444d9f8b4f738da896712bd3ecbe4bbe6 Mon Sep 17 00:00:00 2001 From: charliesome Date: Fri, 28 Jun 2013 16:09:08 +0000 Subject: [PATCH] * numeric.c (fix_mul): remove FIT_SQRT_LONG test as it was causing fix_mul to return an incorrect result for -2147483648*-2147483648 on 64 bit platforms * test/ruby/test_integer_comb.rb (class TestIntegerComb): add test case git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41689 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ numeric.c | 2 -- test/ruby/test_integer_comb.rb | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 065dc035ef..8bc49f6000 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Fri Jun 29 01:08:00 2013 Charlie Somerville + + * numeric.c (fix_mul): remove FIT_SQRT_LONG test as it was causing + fix_mul to return an incorrect result for -2147483648*-2147483648 + on 64 bit platforms + + * test/ruby/test_integer_comb.rb (class TestIntegerComb): add test case + Fri Jun 28 12:26:53 2013 Tanaka Akira * bignum.c (rb_big_and): Allocate new bignum with same size to shorter diff --git a/numeric.c b/numeric.c index 79f8537fdd..6752becc00 100644 --- a/numeric.c +++ b/numeric.c @@ -2728,8 +2728,6 @@ fix_mul(VALUE x, VALUE y) if (FIXABLE(d)) return LONG2FIX(d); return rb_ll2inum(d); #else - if (FIT_SQRT_LONG(a) && FIT_SQRT_LONG(b)) - return LONG2FIX(a*b); if (a == 0) return x; if (MUL_OVERFLOW_FIXNUM_P(a, b)) r = rb_big_mul(rb_int2big(a), rb_int2big(b)); diff --git a/test/ruby/test_integer_comb.rb b/test/ruby/test_integer_comb.rb index 3f5a0aa0a7..548102d034 100644 --- a/test/ruby/test_integer_comb.rb +++ b/test/ruby/test_integer_comb.rb @@ -187,6 +187,7 @@ class TestIntegerComb < Test::Unit::TestCase c = a * b check_class(c) assert_equal(b * a, c, "#{a} * #{b}") + assert_equal(b.send(:*, a), c, "#{a} * #{b}") assert_equal(b, c / a, "(#{a} * #{b}) / #{a}") if a != 0 assert_equal(a.abs * b.abs, (a * b).abs, "(#{a} * #{b}).abs") assert_equal((a-100)*(b-100)+(a-100)*100+(b-100)*100+10000, c, "#{a} * #{b}")