rust/tests/compile-fail/invalid_enum_discriminant.rs
2020-05-01 14:43:59 +02:00

18 lines
453 B
Rust

// 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
// error-pattern: enum value has invalid discriminant: 0x0000002a
use std::mem;
#[repr(C)]
pub enum Foo {
A, B, C, D
}
fn main() {
let f = unsafe { std::mem::transmute::<i32, Foo>(42) };
let _val = mem::discriminant(&f);
}