rust/tests/fail/intrinsics/out_of_bounds_ptr_2.rs

7 lines
209 B
Rust
Raw Normal View History

fn main() {
let v = [0i8; 4];
let x = &v as *const i8;
2022-07-24 13:28:45 -05:00
let x = unsafe { x.offset(isize::MIN) }; //~ERROR: overflowing in-bounds pointer arithmetic
panic!("this should never print: {:?}", x);
}