rust/tests/fail/dangling_pointers/out_of_bounds_read2.rs
2022-06-01 10:53:38 -04:00

6 lines
172 B
Rust

fn main() {
let v: Vec<u8> = vec![1, 2];
let x = unsafe { *v.as_ptr().wrapping_offset(5) }; //~ ERROR out-of-bounds
panic!("this should never print: {}", x);
}