rust/tests/compile-fail/invalid_enum_discriminant.rs

17 lines
307 B
Rust
Raw Normal View History

2018-08-25 04:07:21 -05:00
// Validation makes this fail in the wrong place
// compile-flags: -Zmiri-disable-validation
2018-08-25 04:07:21 -05:00
// 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 _ = mem::discriminant(&f);
}