From b10e575217101af680ab5729382724189f1d5a62 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 21 Sep 2012 21:48:33 -0700 Subject: [PATCH] Add tests for out-of-stack box leak #2555 --- src/test/run-fail/out-of-stack-managed-box.rs | 13 +++++++++++++ src/test/run-fail/out-of-stack-owned-box.rs | 12 ++++++++++++ 2 files changed, 25 insertions(+) create mode 100644 src/test/run-fail/out-of-stack-managed-box.rs create mode 100644 src/test/run-fail/out-of-stack-owned-box.rs diff --git a/src/test/run-fail/out-of-stack-managed-box.rs b/src/test/run-fail/out-of-stack-managed-box.rs new file mode 100644 index 0000000000000..0e65439818b0b --- /dev/null +++ b/src/test/run-fail/out-of-stack-managed-box.rs @@ -0,0 +1,13 @@ +// NB: Not sure why this works. I expect the box argument to leak when +// we run out of stack. Maybe the box annihilator works it out? + +// error-pattern:ran out of stack +fn main() { + eat(move @0); +} + +fn eat( + +a: @int +) { + eat(move a) +} diff --git a/src/test/run-fail/out-of-stack-owned-box.rs b/src/test/run-fail/out-of-stack-owned-box.rs new file mode 100644 index 0000000000000..9af586429f70f --- /dev/null +++ b/src/test/run-fail/out-of-stack-owned-box.rs @@ -0,0 +1,12 @@ +// xfail-test +// error-pattern:ran out of stack +fn main() { + eat(move ~0); +} + +fn eat( + +a: ~int +) { + // Prevent this from being optimized to nothing + eat(move a) +}