]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/dangling_pointer_deref.rs
f2c7ec584fefba2394b6eacf2f6b428b1710836a
[rust.git] / tests / compile-fail / dangling_pointer_deref.rs
1 fn main() {
2     let p = {
3         let b = Box::new(42);
4         &*b as *const i32
5     };
6     let x = unsafe { *p }; //~ ERROR dereferenced after this allocation got freed
7     panic!("this should never print: {}", x);
8 }