]> git.lizzy.rs Git - rust.git/blob - tests/fail/stacked_borrows/illegal_write_despite_exposed1.rs
pointer tag tracking: on creation, log the offsets it is created for
[rust.git] / tests / fail / stacked_borrows / illegal_write_despite_exposed1.rs
1 // compile-flags: -Zmiri-permissive-provenance
2
3 fn main() {
4     unsafe {
5         let root = &mut 42;
6         let addr = root as *mut i32 as usize;
7         let exposed_ptr = addr as *mut i32;
8         // From the exposed ptr, we get a new SRO ptr.
9         let root2 = &*exposed_ptr;
10         // Stack: Unknown(<N), SRO(N), SRO(N+1)
11         // And we test that it is read-only by doing a conflicting write.
12         *exposed_ptr = 0;
13         // Stack: Unknown(<N)
14         let _val = *root2; //~ ERROR: borrow stack
15     }
16 }