Skip to content

1 << (2**40) returns 1 on JRuby #7554

@eregon

Description

@eregon

Environment Information

Provide at least:

  • JRuby version (jruby -v) and command line (flags, JRUBY_OPTS, etc): jruby 9.4.1.0-SNAPSHOT (3.1.0) 2023-01-05 006cf2b9c4 OpenJDK 64-Bit Server VM 17.0.5+8 on 17.0.5+8 +jit [x86_64-linux]
  • Operating system and platform (e.g. uname -a): Linux

Expected Behavior

MRI and TruffleRuby:

$ ruby -e 'p(1 << (2**40))'
-e: failed to allocate memory (NoMemoryError)
$ ruby -e 'p(1 << (2**64))'
-e: failed to allocate memory (NoMemoryError)

Actual Behavior

JRuby:

$ ruby -e 'p(1 << (2**40))'               
1
$ ruby -e 'p(1 << (2**64))'
RangeError: bignum too big to convert into `long'
      << at org/jruby/RubyBignum.java:912
      << at org/jruby/RubyFixnum.java:1285
  <main> at -e:1
... 4 levels...

Related: https://bugs.ruby-lang.org/issues/18518

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions