public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/39796]  New: cin/cout/cerr constructors should run at high priority when possible
@ 2009-04-17 14:26 ian at airs dot com
  2009-04-17 15:06 ` [Bug libstdc++/39796] " paolo dot carlini at oracle dot com
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: ian at airs dot com @ 2009-04-17 14:26 UTC (permalink / raw)
  To: gcc-bugs

libstdc++ ensures that cin/cout/cerr are constructed before they are used, but
the scheme fails when using constructor priorities.  Constructors with a
priority are run before constructors without a priority, which is the
appropriate behaviour.  However, this means that this program:

#include <iostream>
void f1() __attribute__ ((constructor (101)));
void f1() { std::cout << "f1" << std::endl; }
int main() { }

will crash at runtime.  f1 will be run at a user level priority, but it will
run before std::cout is initialized.

I suggest that on systems which support constructor priorities, that we arrange
to run ios_base::Init::Init() at a high priority.  The destructor should also
be run at a high priority, of course.


-- 
           Summary: cin/cout/cerr constructors should run at high priority
                    when possible
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ian at airs dot com


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-02-03 19:49 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-39796-4@http.gcc.gnu.org/bugzilla/>
2012-01-03 16:41 ` [Bug libstdc++/39796] cin/cout/cerr constructors should run at high priority when possible 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
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 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).