2020-02-24 09:22:02 -06:00
|
|
|
// This should fail even without validation/SB
|
|
|
|
// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
|
2018-07-24 15:29:08 -05:00
|
|
|
|
2016-11-17 07:48:34 -06:00
|
|
|
fn main() {
|
2017-02-07 13:28:54 -06:00
|
|
|
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
|
2016-11-17 07:48:34 -06:00
|
|
|
let y = unsafe { &mut *(x as *const i32 as *mut i32) };
|
2018-10-19 04:50:17 -05:00
|
|
|
*y = 42; //~ ERROR tried to modify constant memory
|
2016-11-17 07:48:34 -06:00
|
|
|
assert_eq!(*x, 42);
|
|
|
|
}
|