bug: transmute::<*const T, Option<Box<T>>>(..)
This commit is contained in:
parent
feca81307f
commit
5ea57ccbcd
1 changed files with 13 additions and 0 deletions
13
tests/compile-fail/bugs/option_box_transmute_ptr.rs
Normal file
13
tests/compile-fail/bugs/option_box_transmute_ptr.rs
Normal file
|
@ -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() {}
|
Loading…
Add table
Add a link
Reference in a new issue