Non-Confidential | ![]() | DUI0773J | ||
| ||||
Home > Coding Considerations > Infinite Loops |
armclang considers infinite loops with no side-effects to be undefined behavior, as stated in the C11 and C++11 standards. In certain situations armclang deletes or moves infinite loops, resulting in a program that eventually terminates, or does not behave as expected.
To ensure that a loop executes for an infinite length of time, Arm recommends writing infinite loops in the following way:
void infinite_loop(void) { while (1) asm volatile(""); // this line is considered to have side-effects }
armclang
does not delete or move the loop,
because it has side-effects.