]> git.lizzy.rs Git - rust.git/commitdiff
bug: transmute::<*const T, Option<Box<T>>>(..)
authorOliver Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Fri, 22 Apr 2016 13:04:12 +0000 (15:04 +0200)
committerOliver 'ker' Schneider <git-spam-no-reply9815368754983@oli-obk.de>
Fri, 22 Apr 2016 18:09:00 +0000 (20:09 +0200)
tests/compile-fail/bugs/option_box_transmute_ptr.rs [new file with mode: 0644]

diff --git a/tests/compile-fail/bugs/option_box_transmute_ptr.rs b/tests/compile-fail/bugs/option_box_transmute_ptr.rs
new file mode 100644 (file)
index 0000000..84161da
--- /dev/null
@@ -0,0 +1,13 @@
+#![feature(custom_attribute)]
+#![allow(dead_code, unused_attributes)]
+
+#[miri_run]
+fn option_box_deref() -> i32 {
+    let val = Some(Box::new(42));
+    unsafe {
+        let ptr: *const i32 = std::mem::transmute(val); //~ ERROR: pointer offset outside bounds of allocation
+        *ptr
+    }
+}
+
+fn main() {}