about summary refs log tree commit diff
path: root/src/test/compile-fail/issue-6762.rs
blob: 14dcc4ea8a3a89d2ce2a52ee7bd975eb833af4b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//xfail-test

// Creating a stack closure which references an owned pointer and then
// transferring ownership of the owned box before invoking the stack
// closure results in a crash.

fn twice(x: ~uint) -> uint
{
     *x * 2
}

fn invoke(f : &fn() -> uint)
{
     f();
}

fn main()
{
      let x  : ~uint         = ~9;
      let sq : &fn() -> uint = || { *x * *x };

      twice(x);
      invoke(sq);
}