rust/tests/compile-fail/ptr_offset_overflow.rs

7 lines
182 B
Rust
Raw Normal View History

2019-12-08 01:45:41 +01:00
//error-pattern: overflowing in-bounds pointer arithmetic
fn main() {
let v = [1i8, 2];
let x = &v[1] as *const i8;
2018-11-26 15:31:53 +01:00
let _val = unsafe { x.offset(isize::min_value()) };
}