]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/ptr_offset_0_plus_0.rs
96a9fb8402f689f2007cbe344fe33ae4c7b567d2
[rust.git] / tests / compile-fail / ptr_offset_0_plus_0.rs
1 // error-pattern: invalid use of NULL pointer
2
3 fn main() {
4     let x = 0 as *mut i32;
5     let _x = x.wrapping_offset(8); // ok, this has no inbounds tag
6     let _x = unsafe { x.offset(0) }; // UB despite offset 0, NULL is never inbounds
7 }