rust/tests/fail/static_memory_modification3.rs
2022-07-11 11:48:56 +00:00

13 lines
333 B
Rust

// Stacked Borrows detects that we are casting & to &mut and so it changes why we fail
//@compile-flags: -Zmiri-disable-stacked-borrows
use std::mem::transmute;
#[allow(mutable_transmutes)]
fn main() {
unsafe {
let bs = b"this is a test";
transmute::<&[u8], &mut [u8]>(bs)[4] = 42; //~ ERROR: read-only
}
}