From 5ea57ccbcd182b46ff54dc182faa6b5f1ae7737b Mon Sep 17 00:00:00 2001 From: Oliver Schneider Date: Fri, 22 Apr 2016 15:04:12 +0200 Subject: [PATCH] bug: transmute::<*const T, Option>>(..) --- tests/compile-fail/bugs/option_box_transmute_ptr.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 tests/compile-fail/bugs/option_box_transmute_ptr.rs 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 index 000000000000..84161daf88dd --- /dev/null +++ b/tests/compile-fail/bugs/option_box_transmute_ptr.rs @@ -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() {}