Liste des Groupes | Revenir à cl c++ |
On 2025-03-31 16:29, James Kuyper wrote:...
"If it [initialization] is deferred, it strongly happens before any
non-initialization odr-use of any non-inline function or non-inline
variable defined in the same translation unit as the variable to be
initialized.47 It is implementation-defined in which threads and at
which points in the program such deferred dynamic initialization
occurs." (6.9.3.3p5).
>
Therefore, what you need to do is make sure that the object has been
initialized is to access it from a function defined in the same
translation unit.
>
The literalist reading of that wording fails miserably if a real world
program uses a global constructor/initializer to cause some desired
imperative effect outside the C++ runtime state. Examples include
setting the CPU clock frequency of a small system, outputting some kind
of welcome message to the human user etc. etc.
However treating the standard text as an imperfect description of
traditional compiler techniques used for 2nd. Edition compilers makes
much more sense .
Les messages affichés proviennent d'usenet.