Closed
Description
A small app to demonstrate the problem:
fn test(val: u8) {
match val {
256 => print!("0b1110\n"),
512 => print!("0b1111\n"),
_ => print!("fail\n"),
}
}
fn main() {
test(1);
}
Compilation fails in llvm:
% rustc test.rs
test.rs:3:5: 3:11 warning: literal out of range for its type, #[warn(type_overflow)] on by default
test.rs:3 256 => print!("0b1110\n"),
^~~~~~
test.rs:4:5: 4:11 warning: literal out of range for its type, #[warn(type_overflow)] on by default
test.rs:4 512 => print!("0b1111\n"),
^~~~~~
Duplicate integer as switch case
switch i8 %1, label %match_else [
i8 0, label %match_case
i8 0, label %match_case3
]
i8 0
LLVM ERROR: Broken function found, compilation aborted!
Rustc should detect the double label due to overflow.