rust/tests/compile-fail/invalid_char.rs
2020-03-19 08:25:08 +01:00

9 lines
308 B
Rust

// Validation makes this fail in the wrong place
// compile-flags: -Zmiri-disable-validation
fn main() {
assert!(std::char::from_u32(-1_i32 as u32).is_none());
let c = unsafe { std::mem::transmute::<i32, char>(-1) };
let _x = c == 'x'; //~ ERROR interpreting an invalid 32-bit value as a char
}