rust/tests/fail/intrinsics/out_of_bounds_ptr_3.rs
2022-06-01 10:53:38 -04:00

8 lines
225 B
Rust

// 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);
}