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++/9404: stringbuf::sputc doesn't call overflow if output buffer full


>Number:         9404
>Category:       libstdc++
>Synopsis:       stringbuf::sputc doesn't call overflow if output buffer full
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Jan 22 16:46:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
If sb is an instance of a class derived from stringbuf and sb.pptr() == sb.epptr(), calling sb.sputc does not cause overflow to be called.
>How-To-Repeat:
See attachment.
>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="sputcbug.cc"
Content-Disposition: inline; filename="sputcbug.cc"

#include <sstream>
using namespace std;

bool called = false;

class Derived_stringbuf : public stringbuf
{
public:
	int_type overflow(int_type c)
		{
			called = true;
			return stringbuf::overflow(c);
		}

	const char_type* pub_epptr() const
		{
			return epptr();
		}

	const char_type* pub_pptr() const
		{
			return pptr();
		}
};

int main()
{
	Derived_stringbuf dsbuf;
	dsbuf.sputc('c');
	assert(called);
	assert(dsbuf.pub_epptr() == dsbuf.pub_pptr());

	called = false;
	dsbuf.sputc('a');
	assert(called);

	return 0;
}


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