logoalt Hacker News

account42yesterday at 4:07 PM1 replyview on HN

Because a compiler being allowed to assume that a loop always terminates gives it more room to optimize the 99% of loops that aren't supposed to run until the heat death of the universe.


Replies

echoangleyesterday at 4:35 PM

Or you could just detect while loops with constant condition (like the C standard) and not touch any programs that don't exhibit UB while allowing infinite loops for other use cases at zero runtime cost and negligible compile cost.