SPRUIG8J January 2018 – March 2024
Global C++ variables that have constructors and destructors require their constructors to be called during program initialization and their destructors to be called during program termination. The C++ compiler produces a table of constructors to be called at startup.
Constructors for global objects from a single module are invoked in the order declared in the source code, but the relative order of objects from different object files is unspecified.
Global constructors are called after initialization of other global variables and before the main() function is called. Global destructors are invoked during the exit run-time support function, similar to functions registered through atexit.
Section 6.7.2.6 discusses the format of the global constructor table.