blob: d9980e75d6051c694373f733540496c780e79ae4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
//@compile-flags: -Zmiri-tree-borrows
use core::ptr::addr_of_mut;
// Check that the diagnostics correctly report the exact range at fault
// and trim irrelevant events.
fn main() {
unsafe {
let data = &mut [0u8; 16];
// Create and activate a few bytes
let rmut = &mut *addr_of_mut!(data[0..6]);
rmut[3] += 1;
rmut[4] += 1;
rmut[5] += 1;
// Now make them lose some perms
let _v = data[3];
let _v = data[4];
let _v = data[5];
data[4] = 1;
data[5] = 1;
// Final test
rmut[5] += 1; //~ ERROR: /read access through .* is forbidden/
}
}
|