2020-04-14 03:03:10 -05:00
|
|
|
// Make sure we catch this even without Stacked Borrows
|
2022-07-08 11:08:32 -05:00
|
|
|
//@compile-flags: -Zmiri-disable-stacked-borrows
|
2020-03-09 04:22:30 -05:00
|
|
|
use std::mem;
|
|
|
|
|
|
|
|
fn dangling() -> *const u8 {
|
|
|
|
let x = 0u8;
|
|
|
|
&x as *const _
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _x: &i32 = unsafe { mem::transmute(dangling()) }; //~ ERROR dangling reference (use-after-free)
|
|
|
|
}
|