Skip to content

Commit e618259

Browse files
committed
P1874R1 Dynamic Initialization Order of Non-Local Variables in Modules
Fixes NB US 082 (C++20 CD)
1 parent 81f1d68 commit e618259

File tree

1 file changed

+24
-13
lines changed

1 file changed

+24
-13
lines changed

source/basic.tex

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6374,31 +6374,42 @@
63746374
variable template specialization has ordered initialization.
63756375
\end{note}
63766376

6377+
\pnum
6378+
A declaration \tcode{D} is
6379+
\defn{appearance-ordered} before a declaration \tcode{E} if
6380+
\begin{itemize}
6381+
\item \tcode{D} appears in the same translation unit as \tcode{E}, or
6382+
\item the translation unit containing \tcode{E}
6383+
has an interface dependency on the translation unit containing \tcode{D},
6384+
\end{itemize}
6385+
in either case prior to \tcode{E}.
6386+
63776387
\pnum
63786388
Dynamic initialization of non-local variables \tcode{V} and \tcode{W}
63796389
with static storage duration are ordered as follows:
63806390
\begin{itemize}
63816391
\item
6382-
If \tcode{V} and \tcode{W} have
6383-
ordered initialization and \tcode{V} is defined before \tcode{W} within
6384-
a single translation unit, the initialization of \tcode{V} is sequenced
6385-
before the initialization of \tcode{W}.
6386-
6387-
\item
6388-
If \tcode{V} has partially-ordered initialization, \tcode{W} does not have
6389-
unordered initialization, and \tcode{V} is defined before \tcode{W} in
6390-
every translation unit in which \tcode{W} is defined, then
6392+
If \tcode{V} and \tcode{W} have ordered initialization and
6393+
the definition of \tcode{V}
6394+
is appearance-ordered before the definition of \tcode{W}, or
6395+
if \tcode{V} has partially-ordered initialization,
6396+
\tcode{W} does not have unordered initialization, and
6397+
for every definition \tcode{E} of \tcode{W}
6398+
there exists a definition \tcode{D} of \tcode{V}
6399+
such that \tcode{D} is appearance-ordered before \tcode{E}, then
63916400
\begin{itemize}
63926401
\item
6393-
if the program starts a thread\iref{intro.multithread}
6394-
other than the main thread\iref{basic.start.main},
6402+
if the program does not start a thread\iref{intro.multithread}
6403+
other than the main thread\iref{basic.start.main}
6404+
or \tcode{V} and \tcode{W} have ordered initialization and
6405+
they are defined in the same translation unit,
63956406
the initialization of \tcode{V}
6396-
strongly happens before
6407+
is sequenced before
63976408
the initialization of \tcode{W};
63986409
\item
63996410
otherwise,
64006411
the initialization of \tcode{V}
6401-
is sequenced before
6412+
strongly happens before
64026413
the initialization of \tcode{W}.
64036414
\end{itemize}
64046415

0 commit comments

Comments
 (0)