From 5735cb8ec021484a549c5da48b5c6f877ad18bf8 Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Mon, 8 Jun 2020 12:04:20 +0200 Subject: [PATCH] Do a volatile read in stack_overflow test to avoid tail recursion This prevents the compiler from transforming the tail recursive function into a loop, which does not lead to a stack overflow. It also avoids the LLVM bug where functions with side-effect-free endless loops are removed. Thus, the test now also works in `--release` mode. --- tests/stack_overflow.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/stack_overflow.rs b/tests/stack_overflow.rs index 71ad12d6a..845644b45 100644 --- a/tests/stack_overflow.rs +++ b/tests/stack_overflow.rs @@ -23,6 +23,7 @@ pub extern "C" fn _start() -> ! { #[allow(unconditional_recursion)] fn stack_overflow() { stack_overflow(); // for each recursion, the return address is pushed + volatile::Volatile::new(0).read(); // prevent tail recursion optimizations } lazy_static! {