‹ 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. bluGill · · focus · HN ↗
      You are an idiot if you write an infinite loop. An infinite loop is a waste of CPU cycles and energy when run.

      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.

      1. AnimalMuppet · · focus · HN ↗
        Non-trivial infinite loops are very much not an "idiot" thing on embedded systems. "Run until power off" or "run until the warhead detonates" are perfectly normal things to do in that world.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.