Skip to content

Commit

Permalink
Remove UB in test_is_null test
Browse files Browse the repository at this point in the history
  • Loading branch information
KamilaBorowska committed Feb 17, 2019
1 parent 8af675a commit 3281e62
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/libcore/tests/ptr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,17 @@ fn test() {
}

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

let q = unsafe { p.offset(1) };
let q = p.wrapping_offset(1);
assert!(!q.is_null());

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

let mq = unsafe { mp.offset(1) };
let mq = mp.wrapping_offset(1);
assert!(!mq.is_null());

// Pointers to unsized types -- slices
Expand Down

0 comments on commit 3281e62

Please sign in to comment.