<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=utf-8">
<meta name=Generator content="Microsoft Word 15 (filtered)">
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:LMRoman10-Bold;
	panose-1:0 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:LMRoman10-Regular;
	panose-1:0 0 0 0 0 0 0 0 0 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin-top:0cm;
	margin-right:0cm;
	margin-bottom:8.0pt;
	margin-left:0cm;
	line-height:107%;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;}
p.Code, li.Code, div.Code
	{mso-style-name:Code;
	mso-style-link:"Code Zchn";
	margin-top:6.0pt;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:0cm;
	line-height:107%;
	font-size:9.0pt;
	font-family:"Courier New";}
p.CodeCxSpFirst, li.CodeCxSpFirst, div.CodeCxSpFirst
	{mso-style-name:CodeCxSpFirst;
	mso-style-link:"Code Zchn";
	margin-top:6.0pt;
	margin-right:0cm;
	margin-bottom:0cm;
	margin-left:0cm;
	line-height:107%;
	font-size:9.0pt;
	font-family:"Courier New";}
p.CodeCxSpMiddle, li.CodeCxSpMiddle, div.CodeCxSpMiddle
	{mso-style-name:CodeCxSpMiddle;
	mso-style-link:"Code Zchn";
	margin:0cm;
	line-height:107%;
	font-size:9.0pt;
	font-family:"Courier New";}
p.CodeCxSpLast, li.CodeCxSpLast, div.CodeCxSpLast
	{mso-style-name:CodeCxSpLast;
	mso-style-link:"Code Zchn";
	margin-top:0cm;
	margin-right:0cm;
	margin-bottom:6.0pt;
	margin-left:0cm;
	line-height:107%;
	font-size:9.0pt;
	font-family:"Courier New";}
span.CodeZchn
	{mso-style-name:"Code Zchn";
	mso-style-link:Code;
	font-family:"Courier New";}
span.Wording
	{mso-style-name:Wording;
	font-family:"Times New Roman",serif;
	color:black;
	font-weight:normal;}
.MsoChpDefault
	{font-family:"Calibri",sans-serif;}
.MsoPapDefault
	{margin-bottom:8.0pt;
	line-height:107%;}
@page WordSection1
	{size:595.3pt 841.9pt;
	margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
	{page:WordSection1;}
-->
</style>

</head>

<body lang=EN-GB style='word-wrap:break-word'>

<div class=WordSection1>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><a name="_Hlk105434419">Document number: P2633R0 </a></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'>Date: 2022-08-15</p>

<p class=MsoNormal>Reply-to: Justin Cooke &lt;jgc@cems.de&gt;<br>
Target audiences: EWG, SG1 <br>
<br>
</p>

<p class=MsoNormal><span class=CodeZchn><b><span style='font-size:10.0pt;
line-height:107%'>thread_local_inherit</span></b></span><span class=Wording><b><span
style='font-size:12.0pt;line-height:107%;font-family:"Calibri",sans-serif'>   :
  Enhancing thread-local storage </span></b></span></p>

<p class=CodeCxSpFirst><span class=Wording><b><span style='font-size:11.0pt;
line-height:107%;font-family:"Calibri",sans-serif'>&nbsp;</span></b></span></p>

<p class=CodeCxSpLast><span class=Wording><b><span style='font-size:12.0pt;
line-height:107%;font-family:"Calibri",sans-serif'>Abstract</span></b></span><span
class=Wording><span style='font-size:11.0pt;line-height:107%;font-family:"Calibri",sans-serif'>: 
To introduce a new storage class </span></span><span style='font-size:10.0pt;
line-height:107%'>thread_local_inherit</span><span class=Wording><span
style='font-size:11.0pt;line-height:107%;font-family:"Calibri",sans-serif'>,
which differs from </span></span><span style='font-size:10.0pt;line-height:
107%'>thread_local</span><span class=Wording><span style='font-size:12.0pt;
line-height:107%;font-family:"Calibri",sans-serif'> </span></span><span
class=Wording><span style='font-size:11.0pt;line-height:107%;font-family:"Calibri",sans-serif'>in
that variables with </span></span><span style='font-size:10.0pt;line-height:
107%'>thread_local_inherit</span><span class=Wording><span style='font-size:
12.0pt;line-height:107%;font-family:"Calibri",sans-serif'> </span></span><span
class=Wording><span style='font-size:11.0pt;line-height:107%;font-family:"Calibri",sans-serif'>storage
are initialized with the value held by the calling thread’s instance of the
variable.  Only trivially copyable types may have </span></span><span
style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span><span
class=Wording><span style='font-size:12.0pt;line-height:107%;font-family:"Calibri",sans-serif'>
</span></span><span class=Wording><span style='font-size:11.0pt;line-height:
107%;font-family:"Calibri",sans-serif'>storage. Their special initialization occurs
during static inititalization of the child thread, before the thread creation
utility returns to the calling thread. </span></span></p>

<p class=MsoNormal><b>&nbsp;</b></p>

<p class=MsoNormal><b><span style='font-size:12.0pt;line-height:107%'>Motivation</span></b>:<span
class=Wording><span style='font-family:"Calibri",sans-serif'>  </span></span><span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>thread_local</span></span><span
class=Wording><span style='font-size:12.0pt;line-height:107%;font-family:"Calibri",sans-serif'>
</span></span><span class=Wording><span style='font-family:"Calibri",sans-serif'>variables
are initialized <i>de novo</i> on thread creation, without regard to the values
they held in the calling thread. However, there are often data that the child
thread would like to inherit from the caller, but thenceforth maintain separate
instances of. While it is possible to pass such data to a thread in arguments
to its top-level function, the required information is typically not readily available
in the context where the caller creates the thread. Indeed, the function creating
the thread (or the programmer writing it) may not know of the existence of the data
nor that the child thread needs them. Other methods of passing data to threads
are cumbersome and likewise require the programmer to know what data need to be
passed. There is merit in a language solution that supplies the required data
automatically to the called thread, at the point and in the scope where they
are required.</span></span></p>

<p class=MsoNormal><span class=Wording><b><span style='font-family:"Calibri",sans-serif'>&nbsp;</span></b></span></p>

<p class=MsoNormal><span class=Wording><b><span style='font-size:12.0pt;
line-height:107%;font-family:"Calibri",sans-serif'>Description</span></b></span><span
class=Wording><b><span style='font-family:"Calibri",sans-serif'>: </span></b></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'>Only variables of
a trivially copyable type can be declared with the proposed new storage class
specifier </span></span><span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>thread_local_inherit. </span></span>The effect of the <span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span>
specifier is equivalent to the effect of <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>thread_local </span></span>except
with respect to initialization.<span class=Wording><span style='font-family:
"Calibri",sans-serif'>  In the main thread only, a variable declared with </span></span><span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'> is statically and
dynamically initialized according to the same rules as for </span></span><span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>thread_local</span></span><span
class=Wording><span style='font-size:12.0pt;line-height:107%;font-family:"Calibri",sans-serif'>
</span></span><span class=Wording><span style='font-family:"Calibri",sans-serif'>variables.
 During creation of a child thread, each </span></span><span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span><span
class=Wording> </span>variable is statically initialized to a trivial copy of
the calling thread’s instance of the variable. A <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>variable will be dynamically
initialized in the child thread only if it is not already completely
initialized. A <span class=CodeZchn><span style='font-size:10.0pt;line-height:
107%'>thread_local_inherit</span></span><span class=Wording> </span>variable is
considered completely initialized when it has been dynamically initialized, or when
it has been statically initialized to a trivial copy of a completely
initialized instance of the variable (<i>note</i>: intentionally recursive
definition).  If it is not already completely initialized, a <span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span><span
class=Wording> </span>variable is dynamically initialized in the child thread
according to the same rules as for <span class=CodeZchn><span style='font-size:
10.0pt;line-height:107%'>thread_local</span></span> variables. The effect of
these rules is that when a <span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>thread_local_inherit</span></span> variable is first used
during a thread’s execution, there will have been exactly one dynamic
initialization in the chain of copies leading to the current instance of the
variable. To prevent data races, all static initialization in a child thread is
sequenced before the thread’s constructor returns to the parent thread.  </p>

<p class=MsoNormal>The destructor of a <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span>
object will be called on thread termination if the object is completely initialized,
i.e. when it has either itself been dynamically initialized or has been
statically initialized with a copy of a completely initialized instance of the
variable. </p>

<p class=MsoNormal><i>Note</i>: In the existing standard, 28.3.2 <span
style='font-family:LMRoman10-Bold'>[cfenv.thread] in effect </span>specifies
that the floating point environment, considered as a variable, behaves as if it
were declared with the proposed <span class=CodeZchn><span style='font-size:
10.0pt;line-height:107%'>thread_local_inherit</span></span> storage specifier. </p>

<p class=MsoNormal><b><span style='font-size:12.0pt;line-height:107%'>&nbsp;</span></b></p>

<p class=MsoNormal><b><span style='font-size:12.0pt;line-height:107%'>Effect on
existing code</span></b><b>:</b>  The token <span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span><span
style='font-size:12.0pt;line-height:107%'> </span>becomes unavailable as an
identifier.</p>

<p class=MsoNormal><b>&nbsp;</b></p>

<p class=MsoNormal><b><span style='font-size:12.0pt;line-height:107%'>Wording</span></b><span
class=Wording>:  (edits to N4910)</span></p>

<p class=MsoNormal><span class=Wording>Table 5: Keywords                                                                                                                  [tab:lex.key]</span></p>

<p class=Code><span class=Wording><span style='line-height:107%;font-family:
"Courier New";color:windowtext;background:lime'>thread_local_inherit</span></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><b><span style='font-family:LMRoman10-Bold;color:black'>&nbsp;</span></b></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><b>6.7.4 Indeterminate values                                                                                                     </b>[basic.indet]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><sup>1</sup> …</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>[<i>Note 1</i> : Objects with static or thread
storage duration are <u><span style='background:lime'>statically</span></u> <s><span
style='background:red'>zero-</span></s>initialized, see 6.9.3.2<i>. —end note</i>]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><b>&nbsp;</b></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><b>6.7.5.3 Thread storage duration</b>                                                                                            [basic.stc.thread]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><sup>1 </sup>All variables declared with the </span><span
class=CodeZchn><span style='font-size:10.0pt'>thread_local</span></span><span
class=Wording><span style='font-size:12.0pt'> </span><u><span style='background:
lime'>or </span></u></span><span class=CodeZchn><u><span style='font-size:10.0pt;
background:lime'>thread_local_inherit</span></u></span><span class=Wording><span
style='font-size:12.0pt'> </span>keyword have thread storage duration. The
storage for these entities lasts for the duration of the thread in which they
are created. There is a distinct object or reference per thread, and use of the
declared name refers to the entity associated with the current thread. <u><span
style='background:lime'>If a variable declared with the</span></u></span><span
class=Wording><u><span style='font-size:10.0pt;background:lime'> </span></u></span><span
class=CodeZchn><u><span style='font-size:10.0pt;background:lime'>thread_local_inherit</span></u></span><span
class=Wording><u><span style='background:lime'> keyword is not of trivially
copyable type (6.8.1), the program is ill-formed (diagnostic required). </span></u></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>&nbsp;</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><b>6.9.3.2 Static initialization                                                                                                      </b></span><b><span
style='font-size:10.0pt;font-family:LMRoman10-Bold'> </span></b><span
class=Wording>[basic.start.static]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><sup>2</sup> Constant initialization is performed if
a variable or temporary object with static or thread storage duration is
constant-initialized (7.7).  If constant initialization is not performed, a
variable with static storage duration (6.7.5.2) or thread storage duration
(6.7.5.3) is zero-initialized (9.4<u>).  <span style='background:lime'>In
threads other than the main thread (6.9.3.1), a variable declared with the </span></u></span><span
class=CodeZchn><u><span style='font-size:10.0pt;background:lime'>thread_local_inherit</span></u></span><span
class=Wording><u><span style='font-size:12.0pt;background:lime'> </span><span
style='background:lime'>specifier (6.7.5.3) is not constant- or
zero-initialized, but instead is initialized as a trivial copy (6.8.1) of the calling
thread’s instance of that variable</span></u><span style='background:lime'>.</span>
Together, zero-initialization, <s><span style='background:red'>and</span></s>
constant initialization <u><span style='background:lime'>and trivial copy-initialization
of variables declared with the </span></u></span><span class=CodeZchn><u><span
style='font-size:10.0pt;background:lime'>thread_local_inherit</span></u></span><u><span
style='background:lime'> specifier</span></u><u> </u><span class=Wording>are
called <i>static initialization</i>; all other initialization is <i>dynamic
initialization</i>. All static initialization strongly happens before (6.9.2.2)
any dynamic initialization <u><span style='background:lime'>in the same thread.
All static initialization in a child thread happens strongly before the constructor
of the </span></u></span><span class=CodeZchn><u><span style='font-size:10.0pt;
background:lime'>thread</span></u></span><span class=Wording><u><span
style='background:lime'> (33.3.3) or </span></u></span><span class=CodeZchn><u><span
style='font-size:10.0pt;background:lime'>jthread</span></u></span><span
class=Wording><u><span style='background:lime'> (33.3.4) object associated with
the child thread returns to the calling thread).</span> </u></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>&nbsp;</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><b>6.9.3.3 Dynamic initialization of non-block
variables</b>                                                            [basic.start.dynamic]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><u><sup><span style='background:lime'>8 </span></sup><span
style='background:lime'>The initialization of a variable is complete when its
dynamic initialization is complete.</span> <span style='background:lime'>Dynamic
initialization in this sense includes initialization that was electively performed
statically (6.9.3.2<sup>3</sup>).  A variable declared with the </span></u></span><span
class=CodeZchn><u><span style='font-size:10.0pt;background:lime'>thread_local_inherit</span></u></span><span
class=Wording><u><span style='font-size:12.0pt;background:lime'> </span><span
style='background:lime'>storage specifier is also considered completely initialized
if it has been statically initialized to a trivial copy of a completely
initialized instance of the variable in the calling thread.</span></u></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>&nbsp;</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><u><sup><span style='background:lime'>9</span></sup><span
style='background:lime'> Further dynamic initialization is not performed on a
variable declared with the </span></u></span><span class=CodeZchn><u><span
style='font-size:10.0pt;background:lime'>thread_local_inherit</span></u></span><span
class=Wording><u><span style='font-size:12.0pt;background:lime'> </span><span
style='background:lime'>specifier (6.7.5.3) if it was already completely
initialized by its static initialization (6.9.3.2).</span></u> </span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>&nbsp;</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><b>8.8 Declaration statement                                                                                                      </b>[stmt.dcl]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording><sup>3</sup> Dynamic initialization of a block
variable with static storage duration (6.7.5.2) or thread storage duration (6.7.5.3)
is performed the first time control passes through its declaration<u><span
style='background:lime'>, unless the variable is declared with the </span></u></span><span
class=CodeZchn><u><span style='font-size:10.0pt;background:lime'>thread_local_inherit</span></u></span><span
class=Wording><u><span style='font-size:12.0pt;background:lime'> </span><span
style='background:lime'>specifier and was already completely initialized by its
static initialization (6.9.3.2, 6.9.3.3</span></u><span style='background:lime'>).</span><s><span
style='background:red'>; such a variable is considered initialized upon the
completion of its initialization</span></s>.</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span style='font-size:10.0pt;font-family:LMRoman10-Regular;color:black'>&nbsp;</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>&nbsp;</span></p>

<p class=MsoNormal><span class=Wording><span style='font-family:"Calibri",sans-serif'>Additional
edits:</span></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=CodeZchn><span style='font-size:9.0pt'>thread_local</span></span><span
class=Wording> </span><span class=Wording><span style='font-family:Wingdings'>à</span>
</span><span class=CodeZchn><span style='font-size:9.0pt'>thread_local</span></span><span
class=Wording> <span style='background:lime'>or </span></span><span
class=CodeZchn><span style='font-size:9.0pt;background:lime'>thread_local_inherit</span></span><span
class=CodeZchn><span style='font-size:9.0pt'>  </span></span><span
class=Wording>[9.2.2<sup>1,3,4</sup>, 11.4.1<sup>12</sup>, 11.4.9.3<sup>1</sup>,
13.9.3<sup>3</sup>, 13.9.4<sup>2</sup>]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=CodeZchn><span style='font-size:9.0pt'>&nbsp;</span></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=CodeZchn><span style='font-size:9.0pt'>thread_local</span></span><span
class=Wording> </span><span class=Wording><span style='font-family:Wingdings'>à</span>
</span><span class=CodeZchn><span style='font-size:9.0pt'>thread_local</span></span><span
class=Wording><span style='background:lime'>, </span></span><span
class=CodeZchn><span style='font-size:9.0pt;background:lime'>thread_local_inherit</span></span><span
class=CodeZchn><span style='font-size:9.0pt'>   </span></span><span
class=Wording>[6.7.5.4<sup>1</sup>, 9.1<sup>6</sup>, 9.3.4.1<sup>4</sup>, </span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=CodeZchn><span style='font-size:9.0pt'>&nbsp;</span></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>and </span><span class=CodeZchn><span
style='font-size:9.0pt'>thread_local</span></span><span class=Wording> </span><span
class=Wording><span style='font-family:Wingdings'>à</span> </span><span
class=CodeZchn><span style='font-size:9.0pt'>thread_local</span></span><span
class=Wording> <span style='background:lime'>and </span></span><span
class=CodeZchn><span style='font-size:9.0pt;background:lime'>thread_local_inherit</span></span><span
class=CodeZchn><span style='font-size:9.0pt'>   </span></span><span
class=Wording>[C.5.2<sup>3</sup>]</span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=CodeZchn><span style='font-size:9.0pt'>&nbsp;</span></span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=CodeZchn><span style='font-size:9.0pt'>thread_local</span></span><span
class=Wording> </span><span class=Wording><span style='font-family:Wingdings'>à</span>
</span><span class=CodeZchn><span style='font-size:9.0pt'>thread_local</span></span><span
class=Wording> </span></p>

<p class=MsoNormal style='margin-bottom:0cm;line-height:normal;text-autospace:
none'><span class=Wording>                              </span><span
class=CodeZchn><span style='font-size:9.0pt;background:lime'>thread_local_inherit</span></span><span
class=CodeZchn><span style='font-size:9.0pt'>                 </span></span><span
class=Wording>[9.2.2<sup>1</sup>, A.7.]</span></p>

<p class=MsoNormal><span class=CodeZchn><span style='font-size:9.0pt;
line-height:107%'>&nbsp;</span></span></p>

<p class=MsoNormal><span class=CodeZchn><span style='font-size:9.0pt;
line-height:107%'>&nbsp;</span></span></p>

<p class=MsoNormal><b><span style='font-size:12.0pt;line-height:107%'>Implementation
hints</span></b><span class=Wording><span style='font-family:"Calibri",sans-serif'>: 
In order to ensure that a block-scope variable with static or thread local
storage is dynamically initialized exactly once, such a variable is typically
implemented with an associated hidden status flag that is unset on static
initialization and set on completion of dynamic initialization. Once the flag
is set, the variable will not be dynamically initialized again.  The flag is
optional for a namespace-scope variable declared </span></span><span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>thread_local</span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'> because it would
not normally be exposed to multiple dynamic initialization attempts.</span></span></p>

<p class=MsoNormal><span class=Wording><span style='font-family:"Calibri",sans-serif'>Regardless
of whether it is declared in block or namespace scope, each </span></span><span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'> variable needs an
associated status flag. The flag is unset during static initialization of the
main thread.  On child thread creation, all </span></span><span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span><span
class=Wording><span style='font-size:12.0pt;line-height:107%;font-family:"Calibri",sans-serif'>
</span></span><span class=Wording><span style='font-family:"Calibri",sans-serif'>variables
and their status flags are statically initialized by trivial copy of the values
held by the variables and their flags in the calling thread. Dynamic
initialization of </span></span><span class=CodeZchn><span style='font-size:
10.0pt;line-height:107%'>thread_local_inherit</span></span><span class=Wording><span
style='font-size:12.0pt;line-height:107%;font-family:"Calibri",sans-serif'> </span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'>variables follows
the same rules as for </span></span><span class=CodeZchn><span
style='font-size:10.0pt;line-height:107%'>thread_local</span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'> variables, except
that a variable whose status flag was already set by static initialization
shall not be dynamically initialized.  </span></span></p>

<p class=MsoNormal><span class=Wording><span style='font-family:"Calibri",sans-serif'>Implementations
typically place </span></span><span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>thread_local</span></span><span class=Wording><span
style='font-size:12.0pt;line-height:107%;font-family:"Calibri",sans-serif'> </span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'>variables, along
with any associated status flags, in a special segment, a new instance of which
is created and constant-initialized on thread creation. </span></span><span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span><span
class=Wording><span style='font-size:12.0pt;line-height:107%;font-family:"Calibri",sans-serif'>
</span></span><span class=Wording><span style='font-family:"Calibri",sans-serif'>variables
can likewise be implemented by placing them, with their associated flags, in a
special part of this segment. The entire segment is constant-initialized in the
usual way for the main thread. For a child thread, only the part-segment
reserved for </span></span><span class=CodeZchn><span style='font-size:10.0pt;
line-height:107%'>thread_local</span></span><span class=Wording><span
style='font-family:"Calibri",sans-serif'> variables is constant-initialized in
the usual way, while the part-segment reserved for </span></span><span
class=CodeZchn><span style='font-size:10.0pt;line-height:107%'>thread_local_inherit</span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'> variables is
initialized to a trivial copy of the calling thread’s instance of the part-segment. 
The restriction that </span></span><span class=CodeZchn><span style='font-size:
10.0pt;line-height:107%'>thread_local_inherit</span></span><span class=Wording><span
style='font-size:12.0pt;line-height:107%;font-family:"Calibri",sans-serif'> </span></span><span
class=Wording><span style='font-family:"Calibri",sans-serif'>variables be
trivially copyable ensures that the part-segment can be initialized by a low-level
bulk copy operation.  The thread creator need only know the size of the
part-segment, not the identity or offset of the individual variables within it.
The copy operation should be completed before the thread creator returns to the
calling thread.</span></span></p>

<p class=MsoNormal><span class=CodeZchn><span style='font-size:9.0pt;
line-height:107%'>&nbsp;</span></span></p>

</div>

</body>

</html>
