blob: 0d1bd7929b5b8e0a79aad77cc8bfe2a13e7b2a2c (
plain)
1
2
3
4
5
6
7
8
9
10
11
|
// This should fail even without validation/SB
//@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
#![allow(invalid_reference_casting)]
fn main() {
let x = &1; // the `&1` is promoted to a constant, but it used to be that only the pointer is marked static, not the pointee
let y = unsafe { &mut *(x as *const i32 as *mut i32) };
*y = 42; //~ ERROR: read-only
assert_eq!(*x, 42);
}
|