Skip to content

Commit 1b6997d

Browse files
committed
test: avoid infinite loop in out-of-stack.rs
This fixes #13238. It avoids an infinite loop when compiling the tests with `-g`. Without this change, the debuginfo on `black_box` prevents the method from being inlined, which allows llvm to convert `silent_recurse` into a tail-call. This then loops forever instead of consuming all the stack like it is supposed to. This patch forces inlining `black_box`, which triggers the right error.
1 parent 3961957 commit 1b6997d

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/test/run-pass/out-of-stack.rs

+3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ use std::os;
1717
use std::str;
1818

1919
// lifted from the test module
20+
// Inlining to avoid llvm turning the recursive functions into tail calls,
21+
// which doesn't consume stack.
22+
#[inline(always)]
2023
pub fn black_box<T>(dummy: T) { unsafe { asm!("" : : "r"(&dummy)) } }
2124

2225
fn silent_recurse() {

0 commit comments

Comments
 (0)