You copied the Doc URL to your clipboard.

ARM Compiler Software Development Guide : Infinite Loops

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.

How to write an infinite loop in armclang

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.