public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/3045: global stream objects destructor semantics
@ 2001-06-08 13:08 bkoz
  0 siblings, 0 replies; 2+ messages in thread
From: bkoz @ 2001-06-08 13:08 UTC (permalink / raw)
  To: bkoz, gcc-bugs, gcc-prs, kenny.simpson, theonetruekenny

Synopsis: global stream objects destructor semantics

State-Changed-From-To: feedback->closed
State-Changed-By: bkoz
State-Changed-When: Fri Jun  8 13:08:41 2001
State-Changed-Why:
    Assumed fixed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=3045&database=gcc


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

* libstdc++/3045: global stream objects destructor semantics
@ 2001-06-04  1:26 theonetruekenny
  0 siblings, 0 replies; 2+ messages in thread
From: theonetruekenny @ 2001-06-04  1:26 UTC (permalink / raw)
  To: gcc-gnats; +Cc: kenny.simpson

>Number:         3045
>Category:       libstdc++
>Synopsis:       global stream objects destructor semantics
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Jun 04 01:26:00 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     theonetruekenny@yahoo.com
>Release:        cvs 20010603
>Organization:
>Environment:
source
>Description:
In libstdc++-v3/src/ios.cc, function ios_base::Init::_S_ios_destroy are these lines:
	delete cout.rdbuf();
	delete cin.rdbuf();
	delete cerr.rdbuf();

These are no doubt the counterpart to the following lines from ios_base::Init::_S_ios_create:
	new (&cout) ostream(new filebuf(stdout, ios_base::out, __bufsize));
	new (&cin) istream(new filebuf(stdin, ios_base::in, 1));
	new (&cerr) ostream(new filebuf(stderr, ios_base::out, __bufsize));

However, the use of the rdbuf() method is incorrect. (See previous bug report dealing with rdbuf()).  This use of rdbuf() could lead to badness if cout/cin/cerr/clog were to be redirected.
>How-To-Repeat:
#include <fstream>
#include <iostream>

std::basic_filebuf b1;

int main()
{
  b1.open("foo");
  cout.rdbuf( b1 );
  std::cout << "hello" << std::endl;
  return 0;
}
// at program termination, b1 is deleted by 
// ios_base::Init::_S_ios_destroy,
// and the streambuf created to handle output
// to stdout is leaked.
>Fix:
create three global filebuf's in globals.cc.
add constructors in ios.cc to in-place construct and destroy these filebufs.
modify the constructors for cout/cin/cerr/clog in ios.cc to use these filebufs.
>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2001-06-08 13:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-08 13:08 libstdc++/3045: global stream objects destructor semantics bkoz
  -- strict thread matches above, loose matches on Subject: below --
2001-06-04  1:26 theonetruekenny

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