about summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/both_borrows/illegal_write6.rs
blob: 5c2dfc48e5221b01fbfe92d991b89c72291eea63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//@revisions: stack tree
//@[tree]compile-flags: -Zmiri-tree-borrows

fn main() {
    let x = &mut 0u32;
    let p = x as *mut u32;
    foo(x, p);
}

fn foo(a: &mut u32, y: *mut u32) -> u32 {
    *a = 1;
    let _b = &*a;
    unsafe { *y = 2 };
    //~[stack]^ ERROR: /not granting access .* because that would remove .* which is strongly protected/
    //~[tree]| ERROR: /write access through .* is forbidden/
    return *a;
}