Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
workingjubilee opened this issue Dec 3, 2023 · 4 comments
Closed

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

workingjubilee opened this issue Dec 3, 2023 · 4 comments
Labels
A-fmt Area: `std::fmt` C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@workingjubilee
Copy link
Member

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
@workingjubilee workingjubilee added the C-bug Category: This is a bug. label Dec 3, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 3, 2023
@saethlin
Copy link
Member

saethlin commented Dec 3, 2023

Is this a duplicate of #117949 ?

@workingjubilee
Copy link
Member Author

yup! sorry about that.

@workingjubilee workingjubilee closed this as not planned Won't fix, can't repro, duplicate, stale Dec 3, 2023
@workingjubilee
Copy link
Member Author

@saethlin: I'm not actually sure if the issue you opened is a duplicate
@saethlin: Behold, no constants in the MIR: https://godbolt.org/z/P56ooWxcz

Guess I'm wrong. :P

@workingjubilee workingjubilee reopened this Dec 3, 2023
@workingjubilee workingjubilee added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-fmt Area: `std::fmt` labels Dec 3, 2023
@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 4, 2023
@gurry
Copy link
Contributor

gurry commented Dec 4, 2023

A duplicate of #115423

@m-ou-se m-ou-se closed this as not planned Won't fix, can't repro, duplicate, stale Dec 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-fmt Area: `std::fmt` C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants