-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
rvalues don't live long enough when using "ref" #3217
Copy link
Copy link
Closed
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Description
This code does a use-after-free:
fn main() {
let msg;
match some(~"Hello") {
some(ref m) => {
msg = m;
},
none => { fail }
}
io::println(*msg);
}
Should it not compile? Or should liveness/borrowck ensure that the string live as long as the escaped reference?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
A-lifetimesArea: Lifetimes / regionsArea: Lifetimes / regionsI-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.Issue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.
Type
Fields
Give feedbackNo fields configured for issues without a type.