rust/tests/compile-fail/invalid_enum_discriminant.rs
2018-11-26 15:31:53 +01:00

17 lines
310 B
Rust

// Validation makes this fail in the wrong place
// compile-flags: -Zmiri-disable-validation
// error-pattern: invalid enum discriminant
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);
}