Closed
Description
The following program will write to freed memory:
#![feature(unboxed_closures, overloaded_calls)]
fn main() {
let mut v = vec![];
let ref f = |&:| { v.push(0u); v.get_mut(0) };
let x = (*f)();
for _ in range(0u, 5) {
(*f)();
}
*x = 42u;
}
Borrowck needs to consider upvars in capture-by-ref, self-by-ref unboxed closures to be aliasable so that mutation and mutable borrows are rejected. I'm working on a patch to do this.
Metadata
Metadata
Assignees
Labels
No labels