Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hash behaves differently when used with FFI::Pointer #2995

Closed
testors opened this issue May 27, 2015 · 3 comments
Closed

Hash behaves differently when used with FFI::Pointer #2995

testors opened this issue May 27, 2015 · 3 comments

Comments

@testors
Copy link

@testors testors commented May 27, 2015

[testors@macpro:~/Work/ruby-shooter]$ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]

[testors@macpro:~/Work/ruby-shooter]$ jruby -v
jruby 9.0.0.0.pre2 (2.2.2) 2015-04-28 2755ae0 Java HotSpot(TM) 64-Bit Server VM 25.5-b02 on 1.8.0_05-b13 +jit [darwin-x86_64]

[testors@macpro:/opt/jruby9k/lib/ruby/stdlib]$ irb
irb(main):001:0> require 'ffi'
=> true
irb(main):002:0> a = FFI::Pointer.new(0)
=> #<FFI::Pointer address=0x00000000000000>
irb(main):003:0> b = FFI::Pointer.new(0)
=> #<FFI::Pointer address=0x00000000000000>
irb(main):004:0> a.eql? b
=> false
irb(main):005:0> Hash[a,true][b]
=> nil

[testors@macpro:~/Work/ruby-shooter]$ jirb
irb(main):001:0> a = FFI::Pointer.new(0)
=> #<FFI::Pointer address=0x0>
irb(main):002:0> b = FFI::Pointer.new(0)
=> #<FFI::Pointer address=0x0>
irb(main):003:0> a.eql? b
=> false
irb(main):004:0> Hash[a,true][b]
=> true
@headius
Copy link
Member

@headius headius commented May 28, 2015

Must be a difference in how FFI::Pointer does hash or eql?. Checking.

@headius
Copy link
Member

@headius headius commented May 28, 2015

Ahh yes. Pointer extends AbstractMemory, which defines eql to be .equals, and these two pointers are "equals".

I guess the question is which behavior is preferable!

headius added a commit that referenced this issue May 28, 2015
@headius headius closed this in 7551aa7 May 28, 2015
@headius
Copy link
Member

@headius headius commented May 28, 2015

I believe @wmeissner accidentally copied this logic over, and so I have removed it.

@headius headius added this to the JRuby 1.7.21 milestone May 28, 2015
headius added a commit that referenced this issue May 28, 2015
headius added a commit that referenced this issue May 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.