rust/src/test/run-fail/too-much-recursion-unwinding.rs

29 lines
531 B
Rust
Raw Normal View History

// error-pattern:ran out of stack
// Test that the task fails after hiting the recursion limit
2012-11-15 19:50:53 -08:00
// during unwinding
fn recurse() {
log(debug, "don't optimize me out");
recurse();
}
2012-11-15 19:50:53 -08:00
struct r {
recursed: *mut bool,
drop unsafe {
if !*(self.recursed) {
*(self.recursed) = true;
recurse();
}
}
2012-11-15 19:50:53 -08:00
}
fn r(recursed: *mut bool) -> r unsafe {
r { recursed: recursed }
}
fn main() {
let mut recursed = false;
2012-11-15 19:50:53 -08:00
let _r = r(ptr::mut_addr_of(&recursed));
recurse();
}