2016-11-17 14:48:34 +01:00
|
|
|
fn main() {
|
2017-02-07 20:28:54 +01: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 14:48:34 +01:00
|
|
|
let y = unsafe { &mut *(x as *const i32 as *mut i32) };
|
2018-07-15 11:21:56 +02:00
|
|
|
*y = 42; //~ ERROR constant evaluation error
|
2018-05-09 17:45:16 +02:00
|
|
|
//~^ NOTE tried to modify constant memory
|
2016-11-17 14:48:34 +01:00
|
|
|
assert_eq!(*x, 42);
|
|
|
|
}
|