Closed matthiaskrgr closed 1 month ago
woth noting that miri rejects this as UB
error: Undefined Behavior: constructing invalid value: encountered 0x62, but expected a boolean --> src/main.rs:19:25 | 19 | assert_eq!(unsafe { *un3.outer }, true); | ^^^^^^^^^^ constructing invalid value: encountered 0x62, but expected a boolean |
---|
I can't reproduce this with latest cg_clif. I don't know if it is fixed now or if I did something wrong.
fn main() {
let b = unsafe { std::mem::transmute::<u8, bool>(2) };
let _x = b == std::hint::black_box(true); //~ ERROR: interpreting an invalid 8-bit value as a bool
}
with Zcodegen-backend=cranelift -Zmir-opt-level=2
still repros this
rustc src/main.rs -Zcodegen-backend=cranelift -Zmir-opt-level=2