The standard specifically states that dynamic initialization of static duration variables (namespace scope and class static members) does not have to occur before main is executed:
“It is implementation-defined whether or not the dynamic initialization (8.5, 9.4, 12.1, 12.6.1) of an object of namespace scope is done before the first statement of main.” IS 3.6.2(3)
Is it not how dynamic initialization is [always?] implemented? What better/easier way to guarantee that the objects are initialized before use?
The standard specifically states that dynamic initialization of static duration variables (namespace scope and
Share
I believe the intention here is to allow dynamic load libraries.
Static variables defined in the libraries are not guaranteed to be initialized before main, but must happen before anything in the specific library is used.