Project

General

Profile

ActionsLike0

Bug #19323

closed

Integer overflow in `Integer#<<`

Added by nobu (Nobuyoshi Nakada) over 2 years ago. Updated almost 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
[ruby-core:111735]

Description

require 'rbconfig/sizeof'
char_bit = RbConfig::LIMITS["UCHAR_MAX"].bit_length
size_max = RbConfig::LIMITS["SIZE_MAX"]
size_bit_max = size_max * char_bit
1 << size_bit_max

The above code raises an "integer overflow" error.

-:5:in `<<': integer overflow: 4611686018427387905 * 4 > 18446744073709551615 (ArgumentError)
	from -:5:in `<main>'

It doesn't seem like a proper or intentional exception.


Related issues 1 (0 open1 closed)

Related to Ruby - Bug #18518: NoMemoryError + [FATAL] failed to allocate memory for twice 1 << largeRejectedActions
#2

Updated by nobu (Nobuyoshi Nakada) over 2 years ago

  • Status changed from Open to Closed
#3

Updated by Eregon (Benoit Daloze) over 2 years ago

  • Related to Bug #18518: NoMemoryError + [FATAL] failed to allocate memory for twice 1 << large added

Updated by usa (Usaku NAKAMURA) almost 2 years ago

  • Backport changed from 2.7: REQUIRED, 3.0: REQUIRED, 3.1: REQUIRED, 3.2: REQUIRED to 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE, 3.2: REQUIRED

Updated by nagachika (Tomoyuki Chikanaga) almost 2 years ago

  • Backport changed from 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE, 3.2: REQUIRED to 2.7: REQUIRED, 3.0: REQUIRED, 3.1: DONE, 3.2: DONE
ActionsLike0

Also available in: Atom PDF