2018-10-17 09:55:59 -05:00
|
|
|
#[repr(u32)]
|
|
|
|
enum Bool { True }
|
|
|
|
|
|
|
|
fn evil(x: &mut Bool) {
|
|
|
|
let x = x as *mut _ as *mut u32;
|
|
|
|
unsafe { *x = 44; } // out-of-bounds enum discriminant
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = Bool::True;
|
|
|
|
evil(&mut x);
|
|
|
|
let _y = x; // reading this ought to be enough to trigger validation
|
2018-11-05 09:05:17 -06:00
|
|
|
//~^ ERROR encountered 44, but expected a valid enum discriminant
|
2018-10-17 09:55:59 -05:00
|
|
|
}
|