Skip to content

Commit 2d5620e

Browse files
committed
Auto merge of #809 - RalfJung:intptrcast, r=<try>
use intptrcast for heap_allocator test; then it should work on Windows
2 parents 72b2e10 + 20753d9 commit 2d5620e

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

.appveyor.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ build_script:
4141

4242
test_script:
4343
# Test miri
44-
- cargo test --release --all-features
44+
- cargo test --release --all-features heap
45+
- false
4546
# Test cargo integration
4647
- cd test-cargo-miri
4748
- '"C:\msys64\mingw64\bin\python3.exe" run-test.py'

tests/run-pass/heap_allocator.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// compile-flags: -Zmiri-seed=
12
#![feature(allocator_api)]
23

34
use std::ptr::NonNull;
@@ -32,14 +33,16 @@ fn check_overalign_requests<T: Alloc>(mut allocator: T) {
3233
let size = 8;
3334
// Greater than `size`.
3435
let align = 16;
35-
// Miri is deterministic; no need to try many times.
36-
let iterations = 1;
36+
37+
let iterations = 5;
3738
unsafe {
3839
let pointers: Vec<_> = (0..iterations).map(|_| {
3940
allocator.alloc(Layout::from_size_align(size, align).unwrap()).unwrap()
4041
}).collect();
4142
for &ptr in &pointers {
42-
assert_eq!((ptr.as_ptr() as usize) % align, 0,
43+
let ptr = ptr.as_ptr();
44+
eprintln!("{:?}, {}", ptr, (ptr as usize) % 256);
45+
assert_eq!((ptr as usize) % align, 0,
4346
"Got a pointer less aligned than requested")
4447
}
4548

@@ -75,7 +78,6 @@ fn box_to_global() {
7578
fn main() {
7679
check_alloc(System);
7780
check_alloc(Global);
78-
#[cfg(not(target_os = "windows"))] // TODO: Inspects allocation base address on Windows; needs intptrcast model
7981
check_overalign_requests(System);
8082
check_overalign_requests(Global);
8183
global_to_box();

0 commit comments

Comments
 (0)