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 [63.128.21.124]) by sourceware.org (Postfix) with ESMTP id BCF2E3851C26 for ; Tue, 15 Dec 2020 18:44:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BCF2E3851C26 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-594-iCPWRJZ_MX2MsYUdgG1Dsw-1; Tue, 15 Dec 2020 13:44:10 -0500 X-MC-Unique: iCPWRJZ_MX2MsYUdgG1Dsw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 414AE100C60B; Tue, 15 Dec 2020 18:44:09 +0000 (UTC) Received: from localhost (unknown [10.33.36.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id E3EBC19C66; Tue, 15 Dec 2020 18:44:08 +0000 (UTC) Date: Tue, 15 Dec 2020 18:44:08 +0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: Re: [committed] libstdc++: Use init_priority attribute for Init object [PR 98108] Message-ID: <20201215184408.GO2309743@redhat.com> References: <20201215114715.GA865968@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201215114715.GA865968@redhat.com> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii; format=flowed 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_H4, 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: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Dec 2020 18:44:13 -0000 On 15/12/20 11:47 +0000, Jonathan Wakely wrote: >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. > 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 >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