Topic: Inline std::ios_base::Init
Author: Anton Bikineev <ant.bikineev@gmail.com>
Date: Mon, 27 Aug 2018 05:19:57 -0700 (PDT)
Raw View
------=_Part_883_908615649.1535372397625
Content-Type: multipart/alternative;
boundary="----=_Part_884_129853343.1535372397625"
------=_Part_884_129853343.1535372397625
Content-Type: text/plain; charset="UTF-8"
The 27.4.2 p3 says:
> The results of including <iostream> in a translation unit shall be as if
> <iostream> defined an instance of ios_base::Init with static storage
> duration.
>
Given that dynamic initialization of inline variables is partially-ordered
(6.8.3.3 p.2), i.e
> If V has partially-ordered initialization, W does not have unordered
> initialization, and V is defined before W in every translation unit in
> which W is defined, then
>
> - if the program starts a thread other than the main thread, the
> initialization of V strongly happens before the initialization of W;
> - otherwise, the initialization of V is sequenced before the
> initialization of W.
> <http://eel.is/c++draft/basic.start.dynamic#2.2.2.sentence-1>
>
> , I wonder if it would make sense to refine the sentence in 27.4.2 p3 with
an addition of the inline specifier for the instance of
```ios_base::Init```. In the libstdc++ implementation that would eliminate
N atomic fetch_and_add intstructions, where N is the number of translation
units.
I'm not sure whether the refinement should go into the Standard or just be
left up to the implementors though. What do you think?
Thanks.
--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/7e629f7d-9161-473f-8e7d-5ff7e3dcd063%40isocpp.org.
------=_Part_884_129853343.1535372397625
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>The 27.4.2 p3 says:</div><blockquote class=3D"gmail_q=
uote" style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 2=
04, 204); padding-left: 1ex;"><div>The results of including <iostream>=
; in a translation unit shall be as if <iostream> defined an instance=
of ios_base::Init with static storage duration.<br></div></blockquote><div=
><br></div><div>Given that dynamic initialization of inline variables is pa=
rtially-ordered (6.8.3.3 p.2), i.e<br></div><blockquote class=3D"gmail_quot=
e" style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 204,=
204); padding-left: 1ex;"><div>If <span class=3D"texttt">V</span> has part=
ially-ordered initialization, <span class=3D"texttt">W</span> does not have
unordered initialization, and <span class=3D"texttt">V</span> is defined be=
fore <span class=3D"texttt">W</span> in
every translation unit in which <span class=3D"texttt">W</span> is defined,=
then
<ul class=3D"itemize"><li id=3D"2.2.1"><div id=3D"2.2.1.sentence-1" class=
=3D"sentence">if the program starts a thread other than the main thread,
the initialization of <span class=3D"texttt">V</span>
strongly happens before
the initialization of <span class=3D"texttt">W</span>;</div></li><li id=3D"=
2.2.2"><div id=3D"2.2.2.sentence-1" class=3D"sentence">otherwise,
the initialization of <span class=3D"texttt">V</span>
is sequenced before
the initialization of <span class=3D"texttt">W</span><a class=3D"hidden_lin=
k" href=3D"http://eel.is/c++draft/basic.start.dynamic#2.2.2.sentence-1">.</=
a></div></li></ul></div></blockquote><div>, I wonder if it would make sense=
to refine the sentence in 27.4.2 p3 with an addition of the inline specifi=
er for the instance of ```ios_base::Init```. In the libstdc++ implementatio=
n that would eliminate N atomic fetch_and_add intstructions, where N is the=
number of translation units.</div><div><br></div><div>I'm not sure whe=
ther the refinement should go into the Standard or just be left up to the i=
mplementors though. What do you think?</div><div><br>Thanks.<br></div></div=
>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/7e629f7d-9161-473f-8e7d-5ff7e3dcd063%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/7e629f7d-9161-473f-8e7d-5ff7e3dcd063=
%40isocpp.org</a>.<br />
------=_Part_884_129853343.1535372397625--
------=_Part_883_908615649.1535372397625--
.