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]

libstdc++/9339: filebuf::pubsetbuf(0, 0) doesn't turn off buffering


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


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