1.. title:: clang-tidy - bugprone-infinite-loop 2 3bugprone-infinite-loop 4====================== 5 6Finds obvious infinite loops (loops where the condition variable is not changed 7at all). 8 9Finding infinite loops is well-known to be impossible (halting problem). 10However, it is possible to detect some obvious infinite loops, for example, if 11the loop condition is not changed. This check detects such loops. A loop is 12considered infinite if it does not have any loop exit statement (``break``, 13``continue``, ``goto``, ``return``, ``throw`` or a call to a function called as 14``[[noreturn]]``) and all of the following conditions hold for every variable in 15the condition: 16 17- It is a local variable. 18- It has no reference or pointer aliases. 19- It is not a structure or class member. 20 21Furthermore, the condition must not contain a function call to consider the loop 22infinite since functions may return different values for different calls. 23 24For example, the following loop is considered infinite `i` is not changed in 25the body: 26 27.. code-block:: c++ 28 29 int i = 0, j = 0; 30 while (i < 10) { 31 ++j; 32 } 33