rust/tests/compile-fail/validity/dangling_ref2.rs
2019-06-23 20:19:26 +02:00

8 lines
219 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 encountered dangling (not entirely in bounds) reference
}