rust/tests/fail/intrinsics/out_of_bounds_ptr_3.rs

7 lines
217 B
Rust
Raw Normal View History

2021-07-17 14:43:32 +02:00
fn main() {
let v = [0i8; 4];
let x = &v as *const i8;
2022-07-24 14:28:45 -04:00
let x = unsafe { x.offset(-1) }; //~ERROR: pointer to 1 byte starting at offset -1 is out-of-bounds
2021-07-17 14:43:32 +02:00
panic!("this should never print: {:?}", x);
}