* [committed] libstdc++: Use init_priority attribute for Init object [PR 98108]
@ 2020-12-15 11:47 Jonathan Wakely
2020-12-15 18:44 ` Jonathan Wakely
0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Wakely @ 2020-12-15 11:47 UTC (permalink / raw)
To: libstdc++, gcc-patches
[-- Attachment #1: Type: text/plain, Size: 356 bytes --]
This causes the global objects that run the <iostream> initialization
code to be constructed earlier, which avoids some bugs in user code due
to incorrectly relying on static initialization order.
libstdc++-v3/ChangeLog:
PR libstdc++/98108
* include/std/iostream (__ioinit): Add init_priority attribute.
Tested powerpc64le-linux. Committed to trunk.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1231 bytes --]
commit cf4ed3b41594b6935a337fe0aaf8149eadf88751
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Tue Dec 15 11:40:06 2020
libstdc++: Use init_priority attribute for Init object [PR 98108]
This causes the global objects that run the <iostream> initialization
code to be constructed earlier, which avoids some bugs in user code due
to incorrectly relying on static initialization order.
libstdc++-v3/ChangeLog:
PR libstdc++/98108
* include/std/iostream (__ioinit): Add init_priority attribute.
diff --git a/libstdc++-v3/include/std/iostream b/libstdc++-v3/include/std/iostream
index f988342b90a..6b2f964f688 100644
--- a/libstdc++-v3/include/std/iostream
+++ b/libstdc++-v3/include/std/iostream
@@ -70,8 +70,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
#endif
//@}
+#if __has_attribute(__init_priority__)
+# define _GLIBCXX_INIT_PRIO(N) __attribute__((__init_priority__(N)))
+#else
+# define _GLIBCXX_INIT_PRIO(N)
+#endif
+
// For construction of filebuffers for cout, cin, cerr, clog et. al.
- static ios_base::Init __ioinit;
+ static ios_base::Init __ioinit _GLIBCXX_INIT_PRIO(90);
+
+#undef _GLIBCXX_INIT_PRIO
_GLIBCXX_END_NAMESPACE_VERSION
} // namespace
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [committed] libstdc++: Use init_priority attribute for Init object [PR 98108]
2020-12-15 11:47 [committed] libstdc++: Use init_priority attribute for Init object [PR 98108] Jonathan Wakely
@ 2020-12-15 18:44 ` Jonathan Wakely
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2020-12-15 18:44 UTC (permalink / raw)
To: libstdc++, gcc-patches
On 15/12/20 11:47 +0000, Jonathan Wakely wrote:
>This causes the global objects that run the <iostream> initialization
>code to be constructed earlier, which avoids some bugs in user code due
>to incorrectly relying on static initialization order.
>
>libstdc++-v3/ChangeLog:
>
> PR libstdc++/98108
> * include/std/iostream (__ioinit): Add init_priority attribute.
>
I've reverted this because it doesn't work on darwin, and isn't
required for correctness anyway.
Tested powerpc64le-linux. Committed to trunk.
>commit cf4ed3b41594b6935a337fe0aaf8149eadf88751
>Author: Jonathan Wakely <jwakely@redhat.com>
>Date: Tue Dec 15 11:40:06 2020
>
> libstdc++: Use init_priority attribute for Init object [PR 98108]
>
> This causes the global objects that run the <iostream> initialization
> code to be constructed earlier, which avoids some bugs in user code due
> to incorrectly relying on static initialization order.
>
> libstdc++-v3/ChangeLog:
>
> PR libstdc++/98108
> * include/std/iostream (__ioinit): Add init_priority attribute.
>
>diff --git a/libstdc++-v3/include/std/iostream b/libstdc++-v3/include/std/iostream
>index f988342b90a..6b2f964f688 100644
>--- a/libstdc++-v3/include/std/iostream
>+++ b/libstdc++-v3/include/std/iostream
>@@ -70,8 +70,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> #endif
> //@}
>
>+#if __has_attribute(__init_priority__)
>+# define _GLIBCXX_INIT_PRIO(N) __attribute__((__init_priority__(N)))
>+#else
>+# define _GLIBCXX_INIT_PRIO(N)
>+#endif
>+
> // For construction of filebuffers for cout, cin, cerr, clog et. al.
>- static ios_base::Init __ioinit;
>+ static ios_base::Init __ioinit _GLIBCXX_INIT_PRIO(90);
>+
>+#undef _GLIBCXX_INIT_PRIO
>
> _GLIBCXX_END_NAMESPACE_VERSION
> } // namespace
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-15 18:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-15 11:47 [committed] libstdc++: Use init_priority attribute for Init object [PR 98108] Jonathan Wakely
2020-12-15 18:44 ` Jonathan Wakely
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).