test for negative offsets

This commit is contained in:
Ralf Jung 2021-07-17 14:43:32 +02:00
parent 46ed39ec20
commit cf26458376

View File

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