diff options
| author | Konrad Borowski <konrad@borowski.pw> | 2019-02-17 13:04:48 +0100 |
|---|---|---|
| committer | Konrad Borowski <konrad@borowski.pw> | 2019-02-17 13:04:48 +0100 |
| commit | 0cf1a912e37e6b3be747deb18a521c1d3657afc0 (patch) | |
| tree | c3b5a48fe237465f0b68d4344b94073d1ffea2d8 /src | |
| parent | 3281e621885e45f0b253acb257a22f12d0623fe8 (diff) | |
| download | rust-0cf1a912e37e6b3be747deb18a521c1d3657afc0.tar.gz rust-0cf1a912e37e6b3be747deb18a521c1d3657afc0.zip | |
Remove UB in test_ptr_subtraction test
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/tests/ptr.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/libcore/tests/ptr.rs b/src/libcore/tests/ptr.rs index 707519e6734..03fe1fe5a7c 100644 --- a/src/libcore/tests/ptr.rs +++ b/src/libcore/tests/ptr.rs @@ -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]; @@ -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); } |
