summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/invalid_char.rs
blob: 699248229445f05dc4c9f0d63850cafdb7536f3c (plain)
1
2
3
4
5
6
7
8
9
10
// Validation makes this fail in the wrong place
// Make sure we find these even with many checks disabled.
//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation

fn main() {
    let c = 0xFFFFFFu32;
    assert!(std::char::from_u32(c).is_none());
    let c = unsafe { std::mem::transmute::<u32, char>(c) };
    let _x = c == 'x'; //~ ERROR: interpreting an invalid 32-bit value as a char
}