rust/tests/compile-fail/out_of_bounds_ptr_2.rs

8 lines
197 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 = [0i8; 4];
let x = &v as *const i8;
let x = unsafe { x.offset(-1) };
panic!("this should never print: {:?}", x);
}