A
AlexWalk
Hello. The C++ textbooks or articles I've read so far state that
static local objects are initialized the first time the control flows
over their declarations. For example, "The C++ Programming Language"
by Bjarne Stroustrup says so. The C++ FAQ Lite says so. But today I
accidentally read about the ISO C++ standard, which doesn't says so.
It says:
[6.7.4] An implementation is permitted to perform
early initialization of other local objects with static storage
duration under the same conditions that an
implementation is permitted to statically initialize an object with
static storage duration in namespace scope
(3.6.2). Otherwise such an object is initialized the first time
control passes through its declaration; ...
Does this mean the statements in those C++ textbooks are incorrect?
Does this mean depending on the "intialization-on-first-entry"
behavior will have some unexpected result?
static local objects are initialized the first time the control flows
over their declarations. For example, "The C++ Programming Language"
by Bjarne Stroustrup says so. The C++ FAQ Lite says so. But today I
accidentally read about the ISO C++ standard, which doesn't says so.
It says:
[6.7.4] An implementation is permitted to perform
early initialization of other local objects with static storage
duration under the same conditions that an
implementation is permitted to statically initialize an object with
static storage duration in namespace scope
(3.6.2). Otherwise such an object is initialized the first time
control passes through its declaration; ...
Does this mean the statements in those C++ textbooks are incorrect?
Does this mean depending on the "intialization-on-first-entry"
behavior will have some unexpected result?