From Jason Turner
Watch on YouTube

Summary

Jason explores the Static Initialization Order Fiasco in C++ (where interdependent global objects may be initialized in an unpredictable order) and demonstrates how C++20's constinit keyword helps address this issue. Using a provider-consumer example, he shows how changing the compilation order can cause runtime errors due to accessing an uninitialized global. The constinit keyword forces compile-time initialization of an object and validates that it can be constant-initialized, preventing the fiasco by ensuring the object is fully initialized before any code executes.

Resources

Tags