Skip to content

Commit d4a85f6

Browse files
committed
add another test for #2068
1 parent c9039de commit d4a85f6

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tests/run-pass/issue-miri-2068-2.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Zmiri-disable-validation
2+
3+
use std::mem::MaybeUninit;
4+
5+
fn main() { unsafe {
6+
let mut x = MaybeUninit::<i64>::uninit();
7+
// Put in a ptr.
8+
x.as_mut_ptr().cast::<&i32>().write_unaligned(&0);
9+
// Overwrite parts of that pointer with 'uninit' through a Scalar.
10+
let ptr = x.as_mut_ptr().cast::<i32>();
11+
*ptr = MaybeUninit::uninit().assume_init();
12+
// Reading this back should hence work fine.
13+
let _c = *ptr;
14+
} }

0 commit comments

Comments
 (0)