From Jason Turner
Watch on YouTube

Summary

This episode reveals a surprising aspect of C++ where infinite loops were undefined behavior before C++26, allowing compilers to make aggressive optimizations. Jason demonstrates how Clang would completely eliminate infinite loops and their containing functions, potentially causing code to fall through into unrelated functions in the binary. As of C++26, infinite loops are no longer undefined behavior, so compilers must preserve them, making this historical quirk a thing of the past.

Resources

Tags