]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/modifying_constants.rs
Rollup merge of #105459 - jyn514:proc-macro-default, r=Mark-Simulacrum
[rust.git] / src / tools / miri / tests / fail / modifying_constants.rs
1 // This should fail even without validation/SB
2 //@compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
3
4 fn main() {
5     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
6     let y = unsafe { &mut *(x as *const i32 as *mut i32) };
7     *y = 42; //~ ERROR: read-only
8     assert_eq!(*x, 42);
9 }