rust/tests/fail/stacked_borrows/unescaped_local.rs

13 lines
336 B
Rust
Raw Normal View History

2022-07-08 11:08:32 -05:00
//@compile-flags: -Zmiri-permissive-provenance
// Make sure we cannot use raw ptrs to access a local that
// we took the direct address of.
fn main() {
let mut x = 42;
let raw = &mut x as *mut i32 as usize as *mut i32;
let _ptr = &mut x;
unsafe {
2022-07-13 17:59:33 -05:00
*raw = 13; //~ ERROR: /write access .* no exposed tags/
2022-06-21 13:40:02 -05:00
}
}