What is the 'Static Initialization Order Fiasco' and how can it be avoided?

Last updated 21 June 2026

  • The fiasco occurs when a global static in one translation unit depends on a global in another, but cross-TU initialization order is unspecified, so the dependency may be used before construction.

  • Fix it with Construct On First Use: a function returning a reference to a static local, initialized on first call (thread-safe since C++11).

  • Also prefer constexpr/constant-initialized globals and minimize global mutable state.

  • https://gist.github.com/MangaD/cfc4759796c72c7a6b0080d1e5ff35db
  • https://github.com/foonathan/atum
  • https://dev.to/pauljlucas/singletons-in-c-4ep2
  • https://dev.to/pauljlucas/const-conundrum-2bfj
All C++ interview questions