Skip to content

Commit c70557d

Browse files
move zero-sized protector dealloc test
1 parent 14dc656 commit c70557d

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

tests/pass/both_borrows/basic_aliasing_model.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@revisions: stack tree
22
//@[tree]compile-flags: -Zmiri-tree-borrows
33
#![feature(allocator_api)]
4+
use std::alloc::{Layout, alloc, dealloc};
45
use std::cell::Cell;
56
use std::ptr;
67

@@ -305,5 +306,14 @@ fn zst() {
305306
let ptr = &raw mut *b as *mut ();
306307
drop(b);
307308
let _ref = &mut *ptr;
309+
310+
// zero-sized protectors do not affect deallocation
311+
fn with_protector(_x: &mut (), ptr: *mut u8, l: Layout) {
312+
// `_x` here is strongly protected but covers zero bytes.
313+
unsafe { dealloc(ptr, l) };
314+
}
315+
let l = Layout::from_size_align(1, 1).unwrap();
316+
let ptr = alloc(l);
317+
with_protector(&mut *ptr.cast::<()>(), ptr, l);
308318
}
309319
}

tests/pass/both_borrows/zero-sized-protected.rs

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)