rust/tests/compile-fail/ptr_offset_overflow.rs

7 lines
170 B
Rust
Raw Normal View History

2018-05-09 08:54:45 -05:00
//error-pattern: attempt to add with overflow
fn main() {
let v = [1i8, 2];
let x = &v[1] as *const i8;
2018-11-26 08:31:53 -06:00
let _val = unsafe { x.offset(isize::min_value()) };
}