2022-07-08 11:08:32 -05:00
|
|
|
//@compile-flags: -Zmiri-permissive-provenance
|
2022-06-24 15:21:47 -05:00
|
|
|
#![feature(strict_provenance)]
|
|
|
|
|
|
|
|
// If we have only exposed read-only pointers, doing a write through a wildcard ptr should fail.
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut x = 0;
|
|
|
|
let _fool = &mut x as *mut i32; // this would have fooled the old untagged pointer logic
|
|
|
|
let addr = (&x as *const i32).expose_addr();
|
|
|
|
let ptr = std::ptr::from_exposed_addr_mut::<i32>(addr);
|
2022-06-24 17:02:25 -05:00
|
|
|
unsafe { *ptr = 0 }; //~ ERROR: borrow stack
|
2022-06-24 15:21:47 -05:00
|
|
|
}
|