libstdc++/5181: basic_ostream::operator<<(streambuf*) wrongly sets eofbit
simon.saunders@net.ntl.com
simon.saunders@net.ntl.com
Sun Dec 23 16:26:00 GMT 2001
>Number: 5181
>Category: libstdc++
>Synopsis: basic_ostream::operator<<(streambuf*) wrongly sets eofbit
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Dec 23 12:36:00 PST 2001
>Closed-Date:
>Last-Modified:
>Originator: Simon Saunders
>Release: 3.0.3
>Organization:
>Environment:
RedHat Linux 6.2
>Description:
After inserting a pointer to a streambuf into an output stream,
the eof bit is set in the output stream and nothing else can
be inserted (unless clear() is called on the stream first).
I think the problem is caused by the function __copy_streambufs
which wrongly sets the eof bit in the output stream.
>How-To-Repeat:
Compile and run this test program. Usage: program infile outfile.
The first argument must be a readable file.
It should copy one file to another and append "Hello\n" to the output file.
With g++ 3.0.3 the "Hello\n" is not written to the output file, and good() returns false.
It works correctly with several other compilers.
/********** Start of test program ***************/
#include <fstream>
#include <iostream>
using namespace std;
int main(int argc, char** argv)
{
if (argc != 3)
return 1;
ifstream i(argv[1]);
ofstream o(argv[2]);
o << i.rdbuf();
cout << o.good() << endl;
o << "Hello\n";
return 0;
}
/************** End of test program ******************/
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the Gcc-bugs
mailing list