2022-07-08 11:08:32 -05:00
|
|
|
//@compile-flags: -Zmiri-permissive-provenance
|
2022-06-24 18:45:35 -05:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
unsafe {
|
|
|
|
let root = &mut 42;
|
|
|
|
let addr = root as *mut i32 as usize;
|
|
|
|
let exposed_ptr = addr as *mut i32;
|
|
|
|
// From the exposed ptr, we get a new SRO ptr.
|
|
|
|
let root2 = &*exposed_ptr;
|
|
|
|
// Stack: Unknown(<N), SRO(N), SRO(N+1)
|
|
|
|
// And we test that it is read-only by doing a conflicting write.
|
2022-07-13 17:59:33 -05:00
|
|
|
// (The write is still fine, using the `root as *mut i32` provenance which got exposed.)
|
2022-06-24 18:45:35 -05:00
|
|
|
*exposed_ptr = 0;
|
|
|
|
// Stack: Unknown(<N)
|
2022-07-13 17:59:33 -05:00
|
|
|
let _val = *root2; //~ ERROR: /read access .* tag does not exist in the borrow stack/
|
2022-06-24 18:45:35 -05:00
|
|
|
}
|
|
|
|
}
|