]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/validity/dangling_ref2.rs
Rollup merge of #102055 - c410-f3r:moar-errors, r=petrochenkov
[rust.git] / src / tools / miri / tests / fail / validity / dangling_ref2.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 main() {
6     let val = 14;
7     let ptr = (&val as *const i32).wrapping_offset(1);
8     let _x: &i32 = unsafe { mem::transmute(ptr) }; //~ ERROR: dangling reference (going beyond the bounds of its allocation)
9 }