rust/tests/fail/intrinsics/out_of_bounds_ptr_1.rs

8 lines
291 B
Rust
Raw Normal View History

fn main() {
let v = [0i8; 4];
let x = &v as *const i8;
// The error is inside another function, so we cannot match it by line
2022-07-24 13:28:45 -05:00
let x = unsafe { x.offset(5) }; //~ERROR: pointer to 5 bytes starting at offset 0 is out-of-bounds
panic!("this should never print: {:?}", x);
}