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

·Hacker News··

Let’s start with a question! Is this program well-defined? 1 2 3 4 int main() { while (true) ; } If you said yes, you’d be wrong — at least before C++26. A while (true); loop with no side effects used to be undefined behaviour. Compilers were free to assume it terminates, and some — Clang in particular — would optimize it away entirely, with spectacular consequences: 1 2 3 4 5 6 7 8 9 10 11 // https://godbolt.org/z/WYMxxeW1T #include <iostream> int main() { while (true) ; } void unreachabl

Read full article →

Related Articles

Samsung is expected to more than double output of its HBM4 and HBM4E DRAM
giuliomagnifico · Hacker News · 10h ago
What happened to the Snowden archive
EXHades · Hacker News · 5h ago
Qwen Image 2.1
jmillikin · Hacker News · 14h ago
Exfiltrate Your Weights
RohanAdwankar · Hacker News · 1d ago
Android 17 is the first since 3.x to add new APIs without releasing to the AOSP
theanonymousone · Hacker News · 2d ago