public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libstdc++/9339: filebuf::pubsetbuf(0, 0) doesn't turn off buffering
@ 2003-01-16 10:36 peturr02
  0 siblings, 0 replies; only message in thread
From: peturr02 @ 2003-01-16 10:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9339
>Category:       libstdc++
>Synopsis:       filebuf::pubsetbuf(0, 0) doesn't turn off buffering
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 16 02:36:01 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
Calling fb.pubsetbuf(0, 0) on a basic_filebuf<> fb only turns off the filebuf's own buffers, not the buffers in the underlying FILE*, so fb remains buffered in effect.
>How-To-Repeat:
See attachment.
>Fix:
Call setbuf(f, 0) after f = fopen() if unbuffered I/O has been requested.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="filesetbufbug.cc"
Content-Disposition: inline; filename="filesetbufbug.cc"

#include <fstream>
#include <cstdio>

using namespace std;

int main()
{
	filebuf fbuf01;
	fbuf01.pubsetbuf(0, 0);
	fbuf01.open("tmp", ios_base::out | ios_base::trunc);
	fbuf01.pubsetbuf(0, 0);
	fbuf01.sputn("g++", 3);

	filebuf fbuf02;
	fbuf02.open("tmp", ios_base::in);
	char buf[256];
	int n = fbuf02.sgetn(buf, 256);

	assert(n > 0);

	return 0;
}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-01-16 10:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-16 10:36 libstdc++/9339: filebuf::pubsetbuf(0, 0) doesn't turn off buffering peturr02

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