Skip to content

Too-big literals can be smuggled into println! #118554

Closed as not planned
Closed as not planned
@workingjubilee

Description

@workingjubilee

I tried this code:

fn main() {
    println!("{}", 0x1234567890123456789_i64);
}

I expected to see this happen:

Denial of an overflowing literal, like the following case would:

fn main() {
    let x = 0x1234567890123456789_i64;
    println!("{}", x);
}

Instead, this happened:

It worked??? It even printed out the right decimal number, 5373003641998677469065

Meta

rustc --version --verbose:

rustc 1.76.0-nightly (8c2b57721 2023-12-01)
binary: rustc
commit-hash: 8c2b57721728233e074db69d93517614de338055
commit-date: 2023-12-01
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-fmtArea: `core::fmt`C-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions