From e1052a0f8d88af185099f4839f87c8c7e0ae11d9 Mon Sep 17 00:00:00 2001 From: Jim Shu Date: Tue, 21 Jan 2020 18:03:33 +0800 Subject: [PATCH] tests/kernel/fatal: add volatile to prevent compiler optimization Initialization of local variable 'illegal' can't be optimized, or the program will jump to the memory contains random value which causes the unexpected behavior. Add volatile to local variable 'illegal' to prevent compiler optimization. Signed-off-by: Jim Shu --- tests/kernel/fatal/src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/kernel/fatal/src/main.c b/tests/kernel/fatal/src/main.c index 14ae937a05d..46f310f58b8 100644 --- a/tests/kernel/fatal/src/main.c +++ b/tests/kernel/fatal/src/main.c @@ -82,7 +82,7 @@ void alt_thread1(void) * and xtensa */ { - long illegal = 0; + volatile long illegal = 0; ((void(*)(void))&illegal)(); } #endif