Skip to content

Commit

Permalink
tests/kernel/fatal: add volatile to prevent compiler optimization
Browse files Browse the repository at this point in the history
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 <cwshu@andestech.com>
  • Loading branch information
cwshu authored and andrewboie committed Jan 22, 2020
1 parent 011da8c commit e1052a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tests/kernel/fatal/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ void alt_thread1(void)
* and xtensa
*/
{
long illegal = 0;
volatile long illegal = 0;
((void(*)(void))&illegal)();
}
#endif
Expand Down

0 comments on commit e1052a0

Please sign in to comment.