rust/tests/run-pass/option_box_transmute_ptr.rs
2016-04-30 01:04:17 -06:00

16 lines
360 B
Rust

#![feature(custom_attribute)]
#![allow(dead_code, unused_attributes)]
// This tests that the size of Option<Box<i32>> is the same as *const i32.
#[miri_run]
fn option_box_deref() -> i32 {
let val = Some(Box::new(42));
unsafe {
let ptr: *const i32 = std::mem::transmute::<Option<Box<i32>>, *const i32>(val);
*ptr
}
}
fn main() {}