-
Notifications
You must be signed in to change notification settings - Fork 13k
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
rustc accepts "---128i8" as a valid constant #34395
Comments
prints Using the constant in any other way, e.g.
errors out:
|
cc @eddyb is that fallout from your new const eval? |
@oli-obk I haven't removed anything, not that I can think of, to cause this. |
Then it's very likely fallout from 735c018 (skipping double negations) |
@oli-obk The remaining error in that testcase feels wrong. |
Actually I think it should be valid code, but yield |
@oli-obk But |
I have no particular opinion on this. But the lint has code handling double negations: rust/src/librustc_lint/types.rs Line 121 in bb4b3fb
|
The double negation is not the issue here. The value of fn main() {
const X: i8 = -100;
const Y: u8 = X as u8;
println!("{}", Y);
} This will also compile just fine and print
|
@dsprenkels I believe the issue is that --128 (aka 128) is an intermediate result of the computation that is out of bounds for the i8. EDIT: The issue is about the fact that the compiler doesn't complain. |
jup, that was a misunderstanding of some code on my part + the issue that processing HIR works the wrong way around (you start with the outer most expression). Reverting 735c018 should do the job |
I thought that it was intended that Pretend I said nothing. |
Revert "skip double negation in const eval" This reverts commit 735c018. fixes rust-lang#34395 The original commit was based on a mis-understanding of the overflowing literal lint. This needs to be ported to beta. r? @eddyb
This is clearly ridiculous, but rustc is perfectly happy with it.
Regression from 1.9.
The text was updated successfully, but these errors were encountered: