rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.79k stars 12.66k forks source link

"warning: Captured variable 'x' not used in closure" presages a crash #1461

Closed jruderman closed 12 years ago

jruderman commented 12 years ago
fn main() {
    let x = ~1;
    let lam_move = lambda[move x]() { };
    lam_move();
}

While compiling:

3:32 warning: Captured variable 'x' not used in closure

While running:

malloc: *** error for object 0x1: pointer being freed was not allocated
graydon commented 12 years ago

My guess is we're not treating the move-capture as cancelling the scope-exit cleanup on x. Should be a reasonably simple fix.