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.
adzm · · focus · HN ↗
kzrdude · · focus · HN ↗
Someone · · focus · HN ↗
muvlon · · focus · HN ↗
gizmo686 · · focus · HN ↗
Sure, that optimization interacts badly with the optimization that removes the infinite loop. But half the point of UB is to avoid needing to deal with such interactions, because they are defined out of existence.
raverbashing · · focus · HN ↗
If I think about asm:
function1:
function2: main: the 2nd call might happen internally due to branch prediction but in practice it shouldn't and the processor fixes thisOh yeah and TFA also goes with:
> The funny bit is that C got this right.(...) but C included one more rule: loops whose controlling expression is a constant expression may not be assumed to terminate.
Well, duh! A broken clock is right twice a day it seems
rcxdude · · focus · HN ↗
[deleted] · · focus · HN ↗
[deleted]