~/talk

Initialization, Shutdown, and constexpr

Talkat CppCon 2018 · 2018-09-23..09-28· [c-and-cpp]
links:none on file
slides:none on file

Explains why global objects fail at startup or shutdown by walking the actual rules: four storage durations, static initialization order fiasco, distinction of zero vs constant vs dynamic initialization, and when lifetime begins or ends for class types. Recommends concrete fixes: prefer constexpr globals or ABSL_CONST_INIT where available, use thread-safe function-local static wrappers that allocate on the heap to avoid destructor races, enable compiler warnings like “warn global constructors,” or call std::quick_exit when safe.

AI-written summary · about

  1. 0:00Introduction
  2. 0:23Why initialization is hard
  3. 3:39Storage duration explained
  4. 8:18Static initialization rules
  5. 9:22Static initialization order fiasco
  6. 12:12Function static locals
  7. 13:15Zero vs constant initialization
  8. 16:11Constant initialization in C++11
  9. 19:04Making globals safe with constexpr
  10. 23:35Object lifetime vs storage duration
  11. 25:18Trivially constructible types
  12. 28:07Global object lifetime graph
  13. 32:02Global destructor rules
  14. 36:12Destruction order guarantees
  15. 40:51Static local thread safety
  16. 41:11Advanced initialization corner cases
  17. 43:59Inline variables in C++17
  18. 46:26Safe global patterns
  19. 48:40Q&A session
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.