Skip to content

Commit

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

#[test]
#[cfg(not(miri))] // This test performs invalid OOB pointer arithmetic
fn test_ptr_subtraction() {
unsafe {
let xs = vec![0,1,2,3,4,5,6,7,8,9];
Expand All @@ -223,8 +222,11 @@ fn test_ptr_subtraction() {
let m_start = xs_mut.as_mut_ptr();
let mut m_ptr = m_start.offset(9);

while m_ptr >= m_start {
loop {
*m_ptr += *m_ptr;
if m_ptr == m_start {
break;
}
m_ptr = m_ptr.offset(-1);
}

Expand Down

0 comments on commit 0cf1a91

Please sign in to comment.