Skip to content

Commit f394d45

Browse files
committed
Merge from rustc
2 parents a0d7bd6 + 12237d0 commit f394d45

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ pub const MIRI_DEFAULT_ARGS: &[&str] = &[
130130
"-Zalways-encode-mir",
131131
"-Zextra-const-ub-checks",
132132
"-Zmir-emit-retag",
133+
"-Zmir-keep-place-mention",
133134
"-Zmir-opt-level=0",
134135
"-Zmir-enable-passes=-CheckAlignment",
135136
];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Make sure we find these even with many checks disabled.
2+
//@compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
3+
4+
fn main() {
5+
let p = {
6+
let b = Box::new(42);
7+
&*b as *const i32
8+
};
9+
unsafe {
10+
let _ = *p; //~ ERROR: dereferenced after this allocation got freed
11+
}
12+
panic!("this should never print");
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: Undefined Behavior: pointer to ALLOC was dereferenced after this allocation got freed
2+
--> $DIR/dangling_pointer_deref_underscore.rs:LL:CC
3+
|
4+
LL | let _ = *p;
5+
| ^^ pointer to ALLOC was dereferenced after this allocation got freed
6+
|
7+
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+
= note: BACKTRACE:
10+
= note: inside `main` at $DIR/dangling_pointer_deref_underscore.rs:LL:CC
11+
12+
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+
error: aborting due to previous error
15+

0 commit comments

Comments
 (0)