‹ BackHN Continuity

Thread

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

173 points · 290 comments · ibobev

  1. ameliaquining · · focus · HN ↗
    The article, most unfortunately, doesn&#x27;t explain why anyone would want infinite loops to be UB in the first place. I found this explanation: <a href="https:&#x2F;&#x2F;www.open-std.org&#x2F;jtc1&#x2F;sc22&#x2F;wg14&#x2F;www&#x2F;docs&#x2F;n1528.htm" rel="nofollow">https:&#x2F;&#x2F;www.open-std.org&#x2F;jtc1&#x2F;sc22&#x2F;wg14&#x2F;www&#x2F;docs&#x2F;n1528.htm
    1. omoikane · · focus · HN ↗
      The article mentions it&#x27;s a halt-on-error pattern:

      <a href="https:&#x2F;&#x2F;www.sandordargo.com&#x2F;blog&#x2F;2026&#x2F;09&#x2F;16&#x2F;cpp26-trivial-infinite-loops#:~:text=But%20why%20would%20anyone%20write%20while%20(true)%3B%20in%20the%20first%20place%3F" rel="nofollow">https:&#x2F;&#x2F;www.sandordargo.com&#x2F;blog&#x2F;2026&#x2F;09&#x2F;16&#x2F;cpp26-trivial-in...

      Edit: sorry, missed the UB bit.

      1. pseudohadamard · · focus · HN ↗
        One minor nit, it&#x27;s not halt-on-error, it&#x27;s restart-on-error since the watchdog then restarts the system. The technical term for this is rejuvenation and it&#x27;s standard practice in SCADA and similar to deal with this-shouldn&#x27;t-happen error conditions.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.