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.
This commit is contained in:
Philipp Oppermann
2020-06-08 12:04:20 +02:00
parent 12d94fd2e9
commit 5735cb8ec0

View File

@@ -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! {