This is the mail archive of the gcc-prs@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++/5181: basic_ostream::operator<<(streambuf*) wrongly sets eofbit



>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:


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