rust/tests/compile-fail/intrinsics/out_of_bounds_ptr_2.rs
2020-04-11 11:36:55 +02:00

8 lines
209 B
Rust

// error-pattern: overflowing in-bounds pointer arithmetic
fn main() {
let v = [0i8; 4];
let x = &v as *const i8;
let x = unsafe { x.offset(-1) };
panic!("this should never print: {:?}", x);
}