rust/tests/compile-fail/validity/dangling_ref2.rs

8 lines
192 B
Rust
Raw Normal View History

2018-10-19 11:38:23 -05:00
use std::mem;
fn main() {
let val = 14;
let ptr = (&val as *const i32).wrapping_offset(1);
let _x: &i32 = unsafe { mem::transmute(ptr) }; //~ ERROR outside bounds of allocation
}