]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/dangling_pointers/dangling_pointer_deref.rs
Rollup merge of #102137 - b-naber:lazy-const-val-conversion, r=lcnr
[rust.git] / src / tools / miri / tests / fail / dangling_pointers / dangling_pointer_deref.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
4 fn main() {
5     let p = {
6         let b = Box::new(42);
7         &*b as *const i32
8     };
9     let x = unsafe { *p }; //~ ERROR: dereferenced after this allocation got freed
10     panic!("this should never print: {}", x);
11 }