Project

General

Profile

Actions

Bug #22452

open

`rb_equal` returns true for `NaN == NaN`

Bug #22452: `rb_equal` returns true for `NaN == NaN`

Added by byroot (Jean Boussier) about 3 hours ago. Updated about 2 hours ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:127157]

Description

I noticed this while trying to cleanup and simplify rb_equal.

>> Float::NAN == Float::NAN
=> false
>> [Float::NAN].index(Float::NAN)
=> 0

I would expect it to return nil.

Array#index is just an example, any core method, and even C extension relying on rb_equal is similarly impacted.

This bug is present on all Ruby versions, except for versions between 2.1 and 2.4.

The bug seem to have been re-introduced in 2.5 by 6e0e067de31511cebec01d176f628442371db879

JRuby seem to have the same behavior, but TruffleRuby correctly returnsnil.


Related issues 1 (0 open — 1 closed)

Related to Ruby - Bug #1720: [NaN] == [NaN] が true になるClosedmrkn (Kenta Murata)Actions
Actions

Also available in: PDF Atom