This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/9423: filebuf::pubsetbuf(0, 0) doesn't turn off buffering if called after open
- From: peturr02 at ru dot is
- To: gcc-gnats at gcc dot gnu dot org
- Date: 23 Jan 2003 18:52:43 -0000
- Subject: libstdc++/9423: filebuf::pubsetbuf(0, 0) doesn't turn off buffering if called after open
- Reply-to: peturr02 at ru dot is
>Number: 9423
>Category: libstdc++
>Synopsis: filebuf::pubsetbuf(0, 0) doesn't turn off buffering if called after open
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Jan 23 18:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: peturr02@ru.is
>Release: gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
Given a filebuf fb, calling fb.pubsetbuf(0, 0) doesn't turn off buffering (as determined by fb.pptr()), if pubsetbuf is called after fb.open().
pubsetbuf(0, 0) is only guaranteed to work if called before the first I/O operation - I don't think open qualifies as an I/O operation.
In any case, this is at worst implementation defined behaviour, and the documentation at
http://gcc.gnu.org/onlinedocs/libstdc++/27_io/howto.html
states that this should work.
>How-To-Repeat:
See attachment.
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="setbufbug2.cc"
Content-Disposition: inline; filename="setbufbug2.cc"
#include <fstream>
using namespace std;
class Derived_filebuf : public filebuf
{
public:
bool is_unbuffered() const
{
return pptr() == NULL && epptr() == NULL;
}
};
int main()
{
Derived_filebuf dfb;
dfb.open("tmp", ios_base::out);
dfb.pubsetbuf(0, 0);
assert(dfb.is_unbuffered());
return 0;
}