~/talk

Safe Static Initialisation & Clean Up in Libraries

Talkat CppNorth 2024 Β· 2024-07-21..07-24Β· [c-and-cpp]
linkedin:ashleyroll
slides:none on file

Explains how C++17+ initializes static storage: constant values go to data/rodata, zeroed ones to BSS, and anything else triggers runtime code pushed into the init array that runs before main and registers destructors with atexit. Shows the cost of dynamic local statics (atomic guard, double-checked lock) and the static-order fiasco. Recommends avoiding dynamic initialization, using compile-time constants, or exposing a small RAII handle (library init/cleanup object + pImpl and a nifty counter for external deps) to control lifetime reliably.

AI-written summary Β· about

  1. 0:00Introduction to talk
  2. 2:00Static storage duration basics
  3. 7:00Program loading and segments
  4. 12:56Initialization phases explained
  5. 16:51Assembly view of initialization
  6. 21:07Linking and dynamic initialization
  7. 24:37Static local variables
  8. 28:11Constructors and destructors
  9. 30:40Common initialization patterns
  10. 37:05Library linking and loading
  11. 39:36Safe library initialization
  12. 43:54Example library design
  13. 52:00Q&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.