]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/ptr_offset_ptr_plus_0.rs
Auto merge of #1308 - RalfJung:miri, r=RalfJung
[rust.git] / tests / compile-fail / ptr_offset_ptr_plus_0.rs
1 // error-pattern: outside bounds of alloc
2
3 fn main() {
4     let x = Box::into_raw(Box::new(0u32));
5     let x = x.wrapping_offset(8); // ok, this has no inbounds tag
6     let _x = unsafe { x.offset(0) }; // UB despite offset 0, the pointer is not inbounds of the only object it can point to
7 }