public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/9318: i/ostream::operator>>/<<(streambuf*) broken
@ 2003-02-11 12:25 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-02-11 12:25 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, paolo, peturr02

Synopsis: i/ostream::operator>>/<<(streambuf*) broken

State-Changed-From-To: analyzed->closed
State-Changed-By: paolo
State-Changed-When: Tue Feb 11 12:25:07 2003
State-Changed-Why:
    Fixed for 3_3 and trunk.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9318


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: libstdc++/9318: i/ostream::operator>>/<<(streambuf*) broken
@ 2003-02-09  9:26 paolo
  0 siblings, 0 replies; 3+ messages in thread
From: paolo @ 2003-02-09  9:26 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, paolo, peturr02

Synopsis: i/ostream::operator>>/<<(streambuf*) broken

Responsible-Changed-From-To: unassigned->paolo
Responsible-Changed-By: paolo
Responsible-Changed-When: Sun Feb  9 09:26:31 2003
Responsible-Changed-Why:
    Working on it.
State-Changed-From-To: open->analyzed
State-Changed-By: paolo
State-Changed-When: Sun Feb  9 09:26:31 2003
State-Changed-Why:
    Confirmed.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9318


^ permalink raw reply	[flat|nested] 3+ messages in thread

* libstdc++/9318: i/ostream::operator>>/<<(streambuf*) broken
@ 2003-01-15 10:06 peturr02
  0 siblings, 0 replies; 3+ messages in thread
From: peturr02 @ 2003-01-15 10:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9318
>Category:       libstdc++
>Synopsis:       i/ostream::operator>>/<<(streambuf*) broken
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 15 02:06:00 PST 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
basic_istream<>::operator>>(basic_streambuf<>*) and basic_ostream<>::operator<<(basic_streambuf<>*) don't copy any characters if the target streambuf is a user-defined unbuffered streambuf.

Reason: __copy_streambufs only performs the copy if ios_base::out is set in the _M_mode member of the target streambuf, but the only basic_streambuf<> members that change _M_mode are setg and setp, and an unbuffered streambuf never calls those.
>How-To-Repeat:
See attachment.
>Fix:
Remove check for _M_mode & ios_base::out.
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="streambufcopybug.cc"
Content-Disposition: inline; filename="streambufcopybug.cc"

#include <sstream>
#include <streambuf>
#include <string>
#include <iostream>

using namespace std;

class Outbuf : public std::streambuf
{
private:
	string str;

protected:
	virtual int_type overflow(int_type c = traits_type::eof())
		{
			if (!traits_type::eq_int_type(c, traits_type::eof()))
				str.push_back(traits_type::to_char_type(c));
		}

public:
	string result() const { return str; }
};

#undef NDEBUG
#include <cassert>

void test01()
{
	istringstream stream ("Bad Moon Rising");
	Outbuf buf;
	stream >> &buf;

	cout << buf.result() << endl;
	cout << stream.str() << endl;
	
	assert(buf.result() == stream.str());
}

void test02()
{
	stringbuf sbuf ("Bad Moon Rising", ios::in);
	Outbuf buf;
	ostream stream (&buf);
	stream << &sbuf;

	cout << buf.result() << endl;
	cout << sbuf.str() << endl;
	
	assert(buf.result() == sbuf.str());
}

int main()
{
	test01();
	test02();

	return 0;
}


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-02-11 12:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-11 12:25 libstdc++/9318: i/ostream::operator>>/<<(streambuf*) broken paolo
  -- strict thread matches above, loose matches on Subject: below --
2003-02-09  9:26 paolo
2003-01-15 10:06 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).