Skip to content

Incorrect check for memory safety in presence of closures #6395

Closed
@silene

Description

@silene

With rust 0.6, the following code produces a segfault. Indeed, at the time of println, *y is no longer a managed pointer to a string, but an arbitrary value crafted by the closure.

enum A { B(@str), C(int) }
fn main() -> () {
  let mut x = B(@"");
  let f = || { x = C(0); };
  match x {
    B(ref y) => { f(); println(*y) },
    C(*) => ()
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions