Skip to content

Commit bf54607

Browse files
committed
test raw pointer tracking; we cannot track raw pointers on Windows
1 parent 70af7ae commit bf54607

File tree

5 files changed

+15
-3
lines changed

5 files changed

+15
-3
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// compile-flags: -Zmiri-track-raw-pointers
2+
// ignore-windows (FIXME: tracking raw pointers does not work on Windows)
3+
//! This demonstrates a provenance problem that requires tracking of raw pointers to be detected.
4+
5+
fn main() {
6+
let mut l = 13;
7+
let raw1 = &mut l as *mut _;
8+
let raw2 = &mut l as *mut _; // invalidates raw1
9+
// Without raw pointer tracking, Stacked Borrows cannot distinguish raw1 and raw2, and thus
10+
// fails to realize that raw1 should not be used any more.
11+
unsafe { *raw1 = 13; } //~ ERROR no item granting write access to tag
12+
unsafe { *raw2 = 13; }
13+
}

tests/run-pass/format.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// compile-flags: -Zmiri-track-raw-pointers
2-
31
fn main() {
42
println!("Hello {}", 13);
53
println!("{:0<width$}", "hello", width = 10);

tests/run-pass/slices.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// compile-flags: -Zmiri-track-raw-pointers
21
#![feature(new_uninit)]
32

43
use std::slice;

tests/run-pass/vec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// compile-flags: -Zmiri-track-raw-pointers
2+
// ignore-windows (FIXME: tracking raw pointers does not work on Windows)
23
// Gather all references from a mutable iterator and make sure Miri notices if
34
// using them is dangerous.
45
fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator<Item = &'a mut T>) {

tests/run-pass/vecdeque.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// compile-flags: -Zmiri-track-raw-pointers
2+
// ignore-windows (FIXME: tracking raw pointers does not work on Windows)
23
use std::collections::VecDeque;
34

45
fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator<Item = &'a mut T>) {

0 commit comments

Comments
 (0)