‹ BackHN Continuity

Thread

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

173 points · 290 comments · ibobev

  1. BobbyTables2 · · focus · HN ↗
    TLDR: For almost 1/6 of a century, the C++ standards broke the simplest infinite loop and only just recently fixed it.

    Idiots!

    Don’t they really that people write real programs to solve real problems? This isn’t a theoretical academic exercise!

    1. Panzerschrek · · focus · HN ↗
      > the simplest infinite loop

      An infinite loop which does nothing is practically useless. So, compilers optimize it out. That's the whole philosophy of modern compilers - to reduce execution time by preserving semantics. In case of an infinite loop elimination it's an optimization making code infinite times faster.

      1. chrystalkey · · focus · HN ↗
        But also very different. If code below this loop executes after elimination and wouldnt have before, that is a very significant change in semantics
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.