Skip to content

Commit 65f42fd

Browse files
committed
test that we cannot access unescaped static memory with a raw ptr
1 parent 730a9ca commit 65f42fd

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
static ARRAY: [u8; 2] = [0, 1];
2+
3+
fn main() {
4+
let ptr_to_first = &ARRAY[0] as *const u8;
5+
// Illegally use this to access the 2nd element.
6+
let _val = unsafe { *ptr_to_first.add(1) }; //~ ERROR borrow stack
7+
}

0 commit comments

Comments
 (0)