‹ BackHN Continuity

Thread

C++26: Trivial infinite loops are no longer undefined behaviour

173 points · 290 comments · ibobev

  1. Aurornis · · focus · HN ↗
    I never would have guessed that the unreachable() function would get executed in that example. Probably not something you’d encounter in practice, though I have seen some weird things happen with layers of #ifdef
    1. saghm · · focus · HN ↗
      That's kind of what you get with UB; the compiler doesn't need to do what you expect.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.