2022-07-08 16:08:32 +00:00
|
|
|
//@compile-flags: -Zmiri-disable-validation
|
2022-04-20 10:39:17 -04:00
|
|
|
|
|
|
|
use std::mem::MaybeUninit;
|
|
|
|
|
2022-06-20 16:00:37 -07:00
|
|
|
fn main() {
|
|
|
|
unsafe {
|
|
|
|
let mut x = MaybeUninit::<i64>::uninit();
|
|
|
|
// Put in a ptr.
|
|
|
|
x.as_mut_ptr().cast::<&i32>().write_unaligned(&0);
|
|
|
|
// Overwrite parts of that pointer with 'uninit' through a Scalar.
|
|
|
|
let ptr = x.as_mut_ptr().cast::<i32>();
|
|
|
|
*ptr = MaybeUninit::uninit().assume_init();
|
|
|
|
// Reading this back should hence work fine.
|
|
|
|
let _c = *ptr;
|
|
|
|
}
|
|
|
|
}
|