about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/static_memory_modification2.rs
blob: d8ae3a57c51e3b1cf31bde1a468afc3494548c76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
// 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 s = "this is a test";
        transmute::<&[u8], &mut [u8]>(s.as_bytes())[4] = 42; //~ ERROR: read-only
    }
}