[ruby-dev:39637] [Bug #2334] 大きなFixnumを値にもつHash#hashが呼び出しごとに変わる

View: New views
2 Messages — Rating Filter:   Alert me  

[ruby-dev:39637] [Bug #2334] 大きなFixnumを値にもつHash#hashが呼び出しごとに変わる

by Tim Pease-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Bug #2334: 大きなFixnumを値にもつHash#hashが呼び出しごとに変わる
http://redmine.ruby-lang.org/issues/show/2334

起票者: Wataru Kimura
ステータス: Open, 優先度: Normal
カテゴリ: core
ruby -v: ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]

大きなFixnumを値にもつHashについてHash#hashの値が呼び出しごとに変わります。

% ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
% irb --simple-prompt
>> h = {:a => 2**61}
=> {:a=>2305843009213693952}
>> h.hash
=> 3933384
>> h.hash
=> 4179968
>> (2**61).class
=> Fixnum
>> (2**62).class
=> Bignum

関連してだと思うのですが
h1.eql? h2 # => true
であるにもかかわらず
h1.hash == h2.hash # => false
となることがあります。
https://trac.macports.org/ticket/22361

% irb --simple-prompt
>> {:a => 2**61}.eql?({:a => 2**61})
=> true
>> {:a => 2**61}.hash == {:a => 2**61}.hash  
=> false

簡単に試してみたところ、値が2**61から2**62-1の範囲で起きるようです。
32bitの場合は2**29から2**30-1の範囲で同様の現象が発生します。


----------------------------------------
http://redmine.ruby-lang.org


[ruby-dev:39647] [Bug #2334](Closed) 大きなFixnumを値にもつHash#hashが呼び出しごとに変わる

by Tim Pease-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

チケット #2334 が更新されました。 (by Yui NARUSE)

ステータス OpenからClosedに変更
進捗 % 0から100に変更

This issue was solved with changeset r25660.
Wataru, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

----------------------------------------
http://redmine.ruby-lang.org/issues/show/2334

----------------------------------------
http://redmine.ruby-lang.org