]> git.lizzy.rs Git - rust.git/commitdiff
test: avoid infinite loop in out-of-stack.rs
authorErick Tryzelaar <erick.tryzelaar@gmail.com>
Wed, 2 Apr 2014 05:07:37 +0000 (22:07 -0700)
committerErick Tryzelaar <erick.tryzelaar@gmail.com>
Fri, 4 Apr 2014 03:28:59 +0000 (20:28 -0700)
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.

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

index d1daa1e365eca7d86408ba8d55b59f7fafcf9d9c..71fde8667032207ba9db4c6a23a5adaa73cbaec0 100644 (file)
@@ -17,6 +17,9 @@
 use std::str;
 
 // lifted from the test module
+// Inlining to avoid llvm turning the recursive functions into tail calls,
+// which doesn't consume stack.
+#[inline(always)]
 pub fn black_box<T>(dummy: T) { unsafe { asm!("" : : "r"(&dummy)) } }
 
 fn silent_recurse() {