rust/tests/compile-fail/static_memory_modification3.rs

13 lines
344 B
Rust
Raw Normal View History

// Validation detects that we are casting & to &mut and so it changes why we fail
// compile-flags: -Zmiri-disable-validation
use std::mem::transmute;
#[allow(mutable_transmutes)]
fn main() {
unsafe {
let bs = b"this is a test";
2018-10-19 04:50:17 -05:00
transmute::<&[u8], &mut [u8]>(bs)[4] = 42; //~ ERROR tried to modify constant memory
}
}