Skip to content

Commit

Permalink
test raw pointer tracking; we cannot track raw pointers on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Oct 28, 2020
1 parent 70af7ae commit bf54607
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
13 changes: 13 additions & 0 deletions tests/compile-fail/stacked_borrows/raw_tracking.rs
@@ -0,0 +1,13 @@
// compile-flags: -Zmiri-track-raw-pointers
// ignore-windows (FIXME: tracking raw pointers does not work on Windows)
//! This demonstrates a provenance problem that requires tracking of raw pointers to be detected.

fn main() {
let mut l = 13;
let raw1 = &mut l as *mut _;
let raw2 = &mut l as *mut _; // invalidates raw1
// Without raw pointer tracking, Stacked Borrows cannot distinguish raw1 and raw2, and thus
// fails to realize that raw1 should not be used any more.
unsafe { *raw1 = 13; } //~ ERROR no item granting write access to tag
unsafe { *raw2 = 13; }
}
2 changes: 0 additions & 2 deletions tests/run-pass/format.rs
@@ -1,5 +1,3 @@
// compile-flags: -Zmiri-track-raw-pointers

fn main() {
println!("Hello {}", 13);
println!("{:0<width$}", "hello", width = 10);
Expand Down
1 change: 0 additions & 1 deletion tests/run-pass/slices.rs
@@ -1,4 +1,3 @@
// compile-flags: -Zmiri-track-raw-pointers
#![feature(new_uninit)]

use std::slice;
Expand Down
1 change: 1 addition & 0 deletions tests/run-pass/vec.rs
@@ -1,4 +1,5 @@
// compile-flags: -Zmiri-track-raw-pointers
// ignore-windows (FIXME: tracking raw pointers does not work on Windows)
// Gather all references from a mutable iterator and make sure Miri notices if
// using them is dangerous.
fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator<Item = &'a mut T>) {
Expand Down
1 change: 1 addition & 0 deletions tests/run-pass/vecdeque.rs
@@ -1,4 +1,5 @@
// compile-flags: -Zmiri-track-raw-pointers
// ignore-windows (FIXME: tracking raw pointers does not work on Windows)
use std::collections::VecDeque;

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

0 comments on commit bf54607

Please sign in to comment.