This commit is contained in:
The Miri Cronjob Bot 2024-04-17 05:09:14 +00:00
parent e8739886f2
commit 2cb03ef739

View file

@ -265,13 +265,15 @@ fn write_does_not_invalidate_all_aliases() {
assert_eq!(*x, 1337); // oops, the value changed! I guess not all pointers were invalidated
}
fn box_into_raw_allows_interior_mutable_alias() { unsafe {
let b = Box::new(std::cell::Cell::new(42));
let raw = Box::into_raw(b);
let c = &*raw;
let d = raw.cast::<i32>(); // bypassing `Cell` -- only okay in Miri tests
// `c` and `d` should permit arbitrary aliasing with each other now.
*d = 1;
c.set(2);
drop(Box::from_raw(raw));
} }
fn box_into_raw_allows_interior_mutable_alias() {
unsafe {
let b = Box::new(std::cell::Cell::new(42));
let raw = Box::into_raw(b);
let c = &*raw;
let d = raw.cast::<i32>(); // bypassing `Cell` -- only okay in Miri tests
// `c` and `d` should permit arbitrary aliasing with each other now.
*d = 1;
c.set(2);
drop(Box::from_raw(raw));
}
}