Skip to content

Commit 3281e62

Browse files
Remove UB in test_is_null test
1 parent 8af675a commit 3281e62

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/libcore/tests/ptr.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,17 @@ fn test() {
4040
}
4141

4242
#[test]
43-
#[cfg(not(miri))] // This test performs invalid OOB pointer arithmetic
4443
fn test_is_null() {
4544
let p: *const isize = null();
4645
assert!(p.is_null());
4746

48-
let q = unsafe { p.offset(1) };
47+
let q = p.wrapping_offset(1);
4948
assert!(!q.is_null());
5049

5150
let mp: *mut isize = null_mut();
5251
assert!(mp.is_null());
5352

54-
let mq = unsafe { mp.offset(1) };
53+
let mq = mp.wrapping_offset(1);
5554
assert!(!mq.is_null());
5655

5756
// Pointers to unsized types -- slices

0 commit comments

Comments
 (0)