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++/9761: filebuf::pbackfail discards previously put back characters


>Number:         9761
>Category:       libstdc++
>Synopsis:       filebuf::pbackfail discards previously put back characters
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Feb 19 17:16:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02 at ru dot is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
If filebuf::sputbackc is called twice in a row, the result of the first sputbackc is lost. It would be better for the second sputbackc to fail than to corrupt the stream. Even better would be to support up to gptr() - eback() put backs.
>How-To-Repeat:
See attachment.
>Fix:

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

#include <fstream>

int main()
{
	using namespace std;

	filebuf fbuf;
	fbuf.open("sputbackcbug3.cc", ios_base::in);

	fbuf.sbumpc();
	fbuf.sbumpc();
	
	if (fbuf.sputbackc('a') == EOF)
		return 0;
	if (fbuf.sputbackc('b') == EOF)
		return 0;

	assert(fbuf.sbumpc() == 'b');
	assert(fbuf.sbumpc() == 'a');

	return 0;
}


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