This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/39796] cin/cout/cerr constructors should run at high priority when possible



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]