about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/uninit_byte_read.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/miri/tests/fail/uninit_byte_read.rs')
-rw-r--r--src/tools/miri/tests/fail/uninit_byte_read.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tools/miri/tests/fail/uninit_byte_read.rs b/src/tools/miri/tests/fail/uninit_byte_read.rs
new file mode 100644
index 00000000000..f1dace0cff9
--- /dev/null
+++ b/src/tools/miri/tests/fail/uninit_byte_read.rs
@@ -0,0 +1,7 @@
+//@compile-flags: -Zmiri-disable-stacked-borrows
+fn main() {
+    let v: Vec<u8> = Vec::with_capacity(10);
+    let undef = unsafe { *v.get_unchecked(5) }; //~ ERROR: uninitialized
+    let x = undef + 1;
+    panic!("this should never print: {}", x);
+}