‹ BackHN Continuity

Thread

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

173 points · 290 comments · ibobev

  1. Panzerschrek · · focus · HN ↗
    I don't see how it can be useful. It's almost always an error to write such a loop. The only reason for it to exist is in very low-level code to do nothing, but for such cases using something like an external function written in assembly is perfectly fine, no C++ standard changes are necessary. It's even makes things harder by complicating the standard with little to no benefits in exchange.
    1. ahy1 · · focus · HN ↗
      It is certainly not almost always an error.

      It is a very normal thing to do when doing embedded programming. It normally means "I do not know how to handle this error. Let the watchdog reset me."

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.