Skip to content

Commit c4f1d3f

Browse files
committed
test that 0 cannot be offset-inbounds by 0
1 parent 61fd7e3 commit c4f1d3f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// error-pattern: outside bounds of allocation
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+
}

0 commit comments

Comments
 (0)