diff --git a/src/test/compile-fail/issue-6762.rs b/src/test/compile-fail/issue-6762.rs new file mode 100644 index 0000000000000..391c1019a9468 --- /dev/null +++ b/src/test/compile-fail/issue-6762.rs @@ -0,0 +1,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); +} \ No newline at end of file