International
The Morning Dev

Only the news worth knowing

‹
 

Release

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

isocpp.org · By Blog Staff ·

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

The Brief

  • C++26 no longer treats trivial infinite loops such as while (true); as undefined behaviour, per P2809R3.
  • Previously, compilers could optimize such loops away entirely.
  • The article also covers the history of C++'s forward-progress rules.

Why it matters

Once C++26 is in effect, a trivial infinite loop is no longer undefined behaviour, so compilers should not optimize it away, which affects code that relies on such loops.

Who’s affected

  • C++ developers

C++26 fixes a surprising source of undefined behaviour: trivial infinite loops such as while (true); , which compilers previously could optimize away entirely. This article explores the history of C++’s forward-progress rules, the changes introduced by P2809R3, and why the fix…

How do you feel about this?

0 Comments