rust/tests/compile-fail/intrinsics/out_of_bounds_ptr_2.rs

8 lines
217 B
Rust
Raw Normal View History

2019-12-07 18:45:41 -06:00
// error-pattern: overflowing in-bounds pointer arithmetic
fn main() {
let v = [0i8; 4];
let x = &v as *const i8;
2021-07-15 13:33:08 -05:00
let x = unsafe { x.offset(isize::MIN) };
panic!("this should never print: {:?}", x);
}