From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id D10C2384B061 for ; Tue, 15 Dec 2020 11:47:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D10C2384B061 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-33-s99V_LGcMcijfLNOg3I9uA-1; Tue, 15 Dec 2020 06:47:18 -0500 X-MC-Unique: s99V_LGcMcijfLNOg3I9uA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EFE30107ACE3; Tue, 15 Dec 2020 11:47:16 +0000 (UTC) Received: from localhost (unknown [10.33.36.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FB6B60854; Tue, 15 Dec 2020 11:47:16 +0000 (UTC) Date: Tue, 15 Dec 2020 11:47:15 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Use init_priority attribute for Init object [PR 98108] Message-ID: <20201215114715.GA865968@redhat.com> MIME-Version: 1.0 X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/mixed; boundary="8t9RHnE3ZwKMSgU+" Content-Disposition: inline X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Dec 2020 11:47:22 -0000 --8t9RHnE3ZwKMSgU+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This causes the global objects that run the 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. --8t9RHnE3ZwKMSgU+ Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" commit cf4ed3b41594b6935a337fe0aaf8149eadf88751 Author: Jonathan Wakely 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 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 --8t9RHnE3ZwKMSgU+--