1 // Make sure we catch this even without validation
2 // compile-flags: -Zmiri-disable-validation
3 
4 // Make sure that we cannot load from memory a `&` that got already invalidated.
main()5 fn main() {
6     let x = &mut 42;
7     let xraw = x as *mut _;
8     let xref = unsafe { &*xraw };
9     let xref_in_mem = Box::new(xref);
10     unsafe { *xraw = 42 }; // unfreeze
11     let _val = *xref_in_mem; //~ ERROR borrow stack
12 }
13