]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/validity/dangling_ref3.rs
Auto merge of #97870 - eggyal:inplace_fold_spec, r=wesleywiser
[rust.git] / src / tools / miri / tests / fail / validity / dangling_ref3.rs
1 // Make sure we catch this even without Stacked Borrows
2 //@compile-flags: -Zmiri-disable-stacked-borrows
3 use std::mem;
4
5 fn dangling() -> *const u8 {
6     let x = 0u8;
7     &x as *const _
8 }
9
10 fn main() {
11     let _x: &i32 = unsafe { mem::transmute(dangling()) }; //~ ERROR: dangling reference (use-after-free)
12 }