File tree Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Expand file tree Collapse file tree 2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change 1+ #![ feature( explicit_tail_calls) ]
2+ #![ allow( incomplete_features) ]
3+
4+ fn g ( x : * const i32 ) {
5+ let _val = unsafe { * x } ; //~ERROR: has been freed, so this pointer is dangling
6+ }
7+
8+ fn f ( _x : * const i32 ) {
9+ let local = 0 ;
10+ let ptr = & local as * const i32 ;
11+ become g( ptr)
12+ }
13+
14+ fn main ( ) {
15+ f ( std:: ptr:: null ( ) ) ;
16+ }
Original file line number Diff line number Diff line change 1+ error: Undefined Behavior: memory access failed: ALLOC has been freed, so this pointer is dangling
2+ --> tests/fail/tail_calls/dangling-local-var.rs:LL:CC
3+ |
4+ LL | let _val = unsafe { *x };
5+ | ^^ memory access failed: ALLOC has been freed, so this pointer is dangling
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+ help: ALLOC was allocated here:
10+ --> tests/fail/tail_calls/dangling-local-var.rs:LL:CC
11+ |
12+ LL | let local = 0;
13+ | ^^^^^
14+ help: ALLOC was deallocated here:
15+ --> tests/fail/tail_calls/dangling-local-var.rs:LL:CC
16+ |
17+ LL | }
18+ | ^
19+ = note: BACKTRACE (of the first span):
20+ = note: inside `g` at tests/fail/tail_calls/dangling-local-var.rs:LL:CC
21+ note: inside `main`
22+ --> tests/fail/tail_calls/dangling-local-var.rs:LL:CC
23+ |
24+ LL | f(std::ptr::null());
25+ | ^^^^^^^^^^^^^^^^^^^
26+
27+ note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
28+
29+ error: aborting due to 1 previous error
30+
You can’t perform that action at this time.
0 commit comments