We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c9039de + d4a85f6 commit 9cfc9fcCopy full SHA for 9cfc9fc
tests/run-pass/issue-miri-2068-2.rs
@@ -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