This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] Fix libstdc++/9523 (and more)
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: Pétur Runólfsson <peturr02 at ru dot is>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 28 Apr 2003 11:41:37 -0500
- Subject: Re: [PATCH] Fix libstdc++/9523 (and more)
- References: <07D05A69A3D0C14FAEA60C3ACE8E5564028F556C@nike.hir.is>
>This patch fixes libstdc++/9523 and a few other related problems in ios_base.
I don't think 9523 is a bug, per se. The other issues you raise, which
are not filed in GNATS, actually are much more important.
I'll let the 9523 test case stand, because I think it's useful to track
what the implementation does in undefined cases like this.
>The standard streams (cin, cout, cerr, clog, wcin, wcout, wcerr, wclog) are
>now only constructed once when the first object of type ios_base::Init is
>constructed and are never destroyed, as required by 27.3 p2 and 27.4.2.1.6
>p3.
Yes, thanks for fixing this. I'm going to add test cases for this if I
can figure it out. I guess I can just do an address check to mark this.
>When the last ios_base::Init object is destroyed the standard output streams
>(cout, cerr, clog, wcout, wcerr, wclog) are now flushed, as required by
>27.4.2.1.6 p4. This in effect reverts the fix for libstdc++/5268, but it
>appears that this is the required behavior and that the test case for 5268
>has undefined behavior.
Yes. Thanks for this.
I made some changes and additions, but this is mostly in.
thanks!
benjamin
>2003-04-26 Petur Runolfsson <peturr02 at ru dot is>
>
> PR libstdc++/9523
> * include/bits/ios_base.h (Init::_S_ios_create,
> Init::_S_ios_destroy): Remove declarations.
> (Init::_S_ios_create_streams, Init::_S_ios_create_buffers,
> Init::_S_ios_flush, Init::_S_ios_destroy_buffers): Declare
> * src/ios.cc (Init::_S_ios_create): Remove
> (Init::_S_ios_create_streams): Create streams with NULL buffers.
> (Init::_S_ios_create_buffers): Create buffers and add to streams.
> (Init::_S_ios_flush): Flush standard output streams.
> (Init::_S_ios_destroy): Rename to...
> (Init::_S_ios_destroy_buffers): this.
> (Init::Init): Only construct streams once.
> (Init::~Init): Flush streams, don't destroy them.
> (ios_base::sync_with_stdio): Don't destroy streams, only buffers.
> * testsuite/27_io/ios_base/sync_with_stdio/9523.cc: New test.
> * testsuite/27_io/objects/char/5.cc: New test.
> * testsuite/27_io/objects/char/5268.cc: Avoid undefined behavior.
> * testsuite/27_io/objects/char/6.cc: New test.
> * testsuite/27_io/objects/char/7.cc: New test.