rust/tests/compile-fail/validity/dangling_ref2.rs
2020-03-19 08:25:08 +01:00

8 lines
226 B
Rust

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 dangling reference (going beyond the bounds of its allocation)
}