Skip to content

Cannot write integer literal for the minimum i128 (-0x8000_0000_0000_0000_0000_0000_0000_0000i128) #38987

Closed
@kennytm

Description

@kennytm

Test case:

#![feature(i128_type)]
fn main() {
    -0x8000_0000_0000_0000i64;  // ok
    -0x8000_0000_0000_0000_0000_0000_0000_0000i128; // Error: attempt to negate with overflow
}

Gives error:

error[E0080]: constant evaluation error
 --> foo.rs:4:5
  |
4 |     -0x8000_0000_0000_0000_0000_0000_0000_0000i128; // Error: attempt to negate with overflow
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to negate with overflow

error: aborting due to previous error

It should compiles fine and the constant should produce the same value as i128::MIN.

For comparison the minimum i64 compiles fine with no warnings.

$ rustc -vV
rustc 1.16.0-nightly (47c8d9fdc 2017-01-08)
binary: rustc
commit-hash: 47c8d9fdcf2e6502cf4ca7d7f059fdc1a2810afa
commit-date: 2017-01-08
host: x86_64-apple-darwin
release: 1.16.0-nightly
LLVM version: 3.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions