]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_addr_of.rs
Rollup merge of #99194 - simlay:simlay/update-rust-gdbgui-gdb-args-to-gdb-cmd, r...
[rust.git] / src / tools / miri / tests / fail / dangling_pointers / dangling_pointer_addr_of.rs
1 // Make sure we find these even with many checks disabled.
2 //@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
3 use std::ptr;
4
5 fn main() {
6     let p = {
7         let b = Box::new(42);
8         &*b as *const i32
9     };
10     let x = unsafe { ptr::addr_of!(*p) }; //~ ERROR: dereferenced after this allocation got freed
11     panic!("this should never print: {:?}", x);
12 }