‹ BackHN Continuity

Thread

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

173 points · 290 comments · ibobev

  1. account42 · · focus · HN ↗
    Unfortunate. There isn't ever a good reason to have an infinite loop so concerned compilers could have just diagnosed this as a warning.
    1. mdspan · · focus · HN ↗
      Compilers can still diagnose something as a warning even if it's not UB.
      1. cppcppcpp · · focus · HN ↗
        Can, yes. Must, no.
      2. tialaramex · · focus · HN ↗
        Warnings are poisoned in C++. It is popular to tell C++ compilers to convert all their warnings into fatal errors. So your only options are "Silently allow probably bad code" and "Program does not compile" because C++ programmers are allergic to nuance.
        1. anticensor · · focus · HN ↗
          Oh you mean the -Wall -Werror crowd.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.