rust/tests/compile-fail/validation_recover1.rs

19 lines
377 B
Rust
Raw Normal View History

2018-05-09 08:54:45 -05:00
// ignore-test validation_op is disabled
#![allow(unused_variables)]
#[repr(u32)]
enum Bool { True }
mod safe {
pub(crate) fn safe(x: &mut super::Bool) {
let x = x as *mut _ as *mut u32;
unsafe { *x = 44; } // out-of-bounds enum discriminant
}
}
fn main() {
let mut x = Bool::True;
safe::safe(&mut x); //~ ERROR: invalid enum discriminant
}