C++26: Trivial infinite loops are no longer undefined behaviour
Thread
Unofficial Hacker News client; not affiliated with Y Combinator.
C++26: Trivial infinite loops are no longer undefined behaviour
Unofficial Hacker News client; not affiliated with Y Combinator.
BobbyTables2 · · focus · HN ↗
Idiots!
Don’t they really that people write real programs to solve real problems? This isn’t a theoretical academic exercise!
bluGill · · focus · HN ↗
If it wasn't so hard to detect (the trivial cases are easy, but it gets hard quickly) I'd say the program should fail to compile.
dare944 · · focus · HN ↗
I, the programmer, will decide what cycles are wasted or not. That the C++ committee thought they knew better is hubris.
bluGill · · focus · HN ↗
If the loop is doing anything then it cannot be optimized away. Only loops with no side effects meaning they are just turning the CPU into a heater count.