Re:AI is forcing us to pay off 40 years of technical debt
by wrs on Thursday November 05, 2026 @12:16AM
(#50375493)
Interestingly, in C++, a trivial infinite loop is undefined behavior. So the compiler not only doesn’t have to detect it, it is allowed to assume you didn’t do it. [0] This is inconvenient when you actually want a trivial infinite loop. (C++26 was going to fix this, but it seems we may not ever get a C++26…)
[0] https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p28...
When you do tell it to, it's usually to warn you that you have accidentally made some really dumb mistake which resulted in a loop which will run forever while doing nothing externally useful to the loop.
Whenever you do something useful with an infinite loop, like come up with additional digits of pi or progressing the search for the next prime number, it results in some form of useful output which touches the environment outside the loop (e.g. print the number to the screen) and so it won't trigger this kind of thing.
Even then, it won't catch every such case. It just so happens that the vast majority of these cases are really easy to show in practice. Something like a loop which does absolutely nothing but loop until it calculates the last digit of pi would be an example of a useless infinite loop that the compiler might not catch, but also an example of one you'd kinda have to go out of your way to make fail in such a way in the first place.