[前][次][番号順一覧][スレッド一覧]

ruby-changes:13860

From: naruse <ko1@a...>
Date: Thu, 5 Nov 2009 20:56:24 +0900 (JST)
Subject: [ruby-changes:13860] Ruby:r25660 (ruby_1_8): * gc.c (rb_obj_id): a Fixnum which is beyond signed long

naruse	2009-11-05 20:56:11 +0900 (Thu, 05 Nov 2009)

  New Revision: 25660

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25660

  Log:
    * gc.c (rb_obj_id): a Fixnum which is beyond signed long
      was converted to a Bignum in calculating its hash.
      [ruby-dev:39637]

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/gc.c
    branches/ruby_1_8/test/ruby/test_hash.rb

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 25659)
+++ ruby_1_8/ChangeLog	(revision 25660)
@@ -1,3 +1,9 @@
+Thu Nov  5 20:49:47 2009  NARUSE, Yui  <naruse@r...>
+
+	* gc.c (rb_obj_id): a Fixnum which is beyond signed long
+	  was converted to a Bignum in calculating its hash.
+	  [ruby-dev:39637]
+
 Thu Nov  5 12:06:35 2009  NARUSE, Yui  <naruse@r...>
 
 	* parse.y (args): use splat_array.
Index: ruby_1_8/test/ruby/test_hash.rb
===================================================================
--- ruby_1_8/test/ruby/test_hash.rb	(revision 25659)
+++ ruby_1_8/test/ruby/test_hash.rb	(revision 25660)
@@ -637,5 +637,7 @@
 
   def test_hash_hash
     assert_equal({0=>2,11=>1}.hash, {11=>1,0=>2}.hash)
+    assert_equal({:a=>2**29}.hash, {:a=>2**29}.hash)
+    assert_equal({:a=>2**61}.hash, {:a=>2**61}.hash)
   end
 end
Index: ruby_1_8/gc.c
===================================================================
--- ruby_1_8/gc.c	(revision 25659)
+++ ruby_1_8/gc.c	(revision 25660)
@@ -2142,7 +2142,7 @@
         return (SYM2ID(obj) * sizeof(RVALUE) + (4 << 2)) | FIXNUM_FLAG;
     }
     if (SPECIAL_CONST_P(obj)) {
-        return LONG2NUM((long)obj);
+        return LONG2FIX((long)obj);
     }
     return (VALUE)((long)obj|FIXNUM_FLAG);
 }

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]