add exposed_only_ro test
This commit is contained in:
parent
d1e7de117c
commit
2deb9e5dae
1 changed files with 12 additions and 0 deletions
12
tests/fail/stacked_borrows/exposed_only_ro.rs
Normal file
12
tests/fail/stacked_borrows/exposed_only_ro.rs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
// compile-flags: -Zmiri-permissive-provenance
|
||||
#![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);
|
||||
unsafe { ptr.write(0) }; //~ ERROR: borrow stack
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue