Home Blogs 2 Wikis 34

Static Initialization Order Fiasco

December 6, 2022 - Reading time: ~1 minute

The static initialization order fiasco refers to the ambiguity in the order that objects with static storage duration in different translation units are initialized in. If an object in one translation unit relies on an object in another translation unit already being initialized, a crash can occur if the compiler decides to initialize them in the wrong order. For example, the order in which .cpp files are specified on the command line may alter this order. The Construct on First Use Idiom can be used to avoid the static initialization order fiasco and ensure that all objects are initialized in the correct order.

Within a single translation unit, the fiasco does not apply because the objects are initialized from top to bottom.

External links

Read more


Thanks for checking out my website. You can read my blogs & wikis and inspect my cv in here also you can look at my projects too.

Hit Counter