public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bkoz at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/39796] cin/cout/cerr constructors should run at high priority when possible
Date: Tue, 21 Apr 2009 02:47:00 -0000	[thread overview]
Message-ID: <20090421024653.25830.qmail@sourceware.org> (raw)
In-Reply-To: <bug-39796-1313@http.gcc.gnu.org/bugzilla/>



------- Comment #3 from bkoz at gcc dot gnu dot org  2009-04-21 02:46 -------

I consider this undefined behaviour, so enhancement is the correct severity. 

People wanting to mess with non-standard init order should probably be taking
steps to insure that libstdc++ is initialized first anyway. Not doing so is
arguably a bug..... especially as it's not hard to do:

ie:
#include <iostream>

void f1() __attribute__ ((constructor (101)));
void f1() 
{ 
  std::ios_base::Init i;
  std::cout << "f1" << std::endl; 
}

int main() { }


But anyway........

libstdc++ is currently not using the first 100 slots reserved for the GNU
implementation as per:

http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html#C_002b_002b-Attributes

No efforts or audit have ever been made as to enshrine a specified init order
for libstd++. Locales, mutexes, and __mt_allocator would all have to be scoped
and modified as code is/was changed. I consider this doable, but probably as
much work in the long run as the efforts for symbol versioning. There may be an
advantage to doing this for size reasons, as then <iostream>'s  

  // For construction of filebuffers for cout, cin, cerr, clog et. al.
  static ios_base::Init __ioinit;

could be killed. 

If there was some kind of real advantage, I would be more into this whole idea.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39796


  parent reply	other threads:[~2009-04-21  2:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-17 14:26 [Bug libstdc++/39796] New: " ian at airs dot com
2009-04-17 15:06 ` [Bug libstdc++/39796] " paolo dot carlini at oracle dot com
2009-04-18  5:40 ` ian at airs dot com
2009-04-21  2:47 ` bkoz at gcc dot gnu dot org [this message]
     [not found] <bug-39796-4@http.gcc.gnu.org/bugzilla/>
2012-01-03 16:41 ` redi at gcc dot gnu.org
2022-11-06 16:16 ` cvs-commit at gcc dot gnu.org
2023-02-03 19:49 ` pinskia at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090421024653.25830.qmail@sourceware.org \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).