Skip to content

Commit cf26458

Browse files
committed
test for negative offsets
1 parent 46ed39e commit cf26458

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+
// error-pattern: pointer to 1 byte starting at offset -1 is out-of-bounds
2+
fn main() {
3+
let v = [0i8; 4];
4+
let x = &v as *const i8;
5+
let x = unsafe { x.offset(-1) };
6+
panic!("this should never print: {:?}", x);
7+
}

0 commit comments

Comments
 (0)