Project

General

Profile

Actions

Bug #2334

closed

大きなFixnumを値にもつHash#hashが呼び出しごとに変わる

Added by kimuraw (Wataru Kimura) over 14 years ago. Updated almost 13 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-darwin10]
[ruby-dev:39637]

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
(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 => 261}.eql?({:a => 261})
=> true
{:a => 261}.hash == {:a => 261}.hash
=> false

簡単に試してみたところ、値が261から262-1の範囲で起きるようです。
32bitの場合は229から230-1の範囲で同様の現象が発生します。
=end


Related issues 1 (0 open1 closed)

Related to Backport191 - Backport #2338: 大きなFixnumを値にもつHash#hashが呼び出しごとに変わるClosedyugui (Yuki Sonoda)11/04/2009Actions
Actions #1

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

Actions

Also available in: Atom PDF

Like0
Like0