Bug #2334
closed大きなFixnumを値にもつHash#hashが呼び出しごとに変わる
Description
=begin
大きなFixnumを値にもつHashについてHash#hashの値が呼び出しごとに変わります。
% ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
% irb --simple-prompt
h = {:a => 261}
=> {:a=>2305843009213693952}
h.hash
=> 3933384
h.hash
=> 4179968
(261).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 => 261}.eql?({:a => 261})
=> true
{:a => 261}.hash == {:a => 261}.hash
=> false
簡単に試してみたところ、値が261から262-1の範囲で起きるようです。
32bitの場合は229から230-1の範囲で同様の現象が発生します。
=end
Updated by naruse (Yui NARUSE) over 14 years ago
- Status changed from Open to Closed
- % Done changed from 0 to 100
=begin
This issue was solved with changeset r22308 (=r25660+25661).
Wataru, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.
=end