-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
inlined inside a println!()
, I get a warning:
fn main() {
println!("{}", 1/false as u8);
}
error[E0080]: constant evaluation error
--> src/main.rs:4:17
|
4 | println!("{}", 1/false as u8);
| ^^^^^^^^^^^^^ attempted to do overflowing math
error: aborting due to previous error
however, when I involve a variable
fn main() {
let x = 1 / false as u8;
println!("{}", x);
}
there is no warning at all but looking at the generated code it is quite clear that this panics:
https://godbolt.org/g/NQmSFM
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.P-mediumMedium priorityMedium priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.