libstdc++/9874: filebuf::seekpos fails if codecvt::encoding() <= 0

peturr02@ru.is peturr02@ru.is
Thu Feb 27 10:26:00 GMT 2003


>Number:         9874
>Category:       libstdc++
>Synopsis:       filebuf::seekpos fails if codecvt::encoding() <= 0
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 27 10:26:01 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     peturr02@ru.is
>Release:        gcc-3.2.1
>Organization:
>Environment:
Red Hat Linux 8.0
>Description:
basic_filebuf<>::seekpos currently calls basic_filebuf<>::seekoff, which makes seekpos useless for variable-width encodings (where codecvt<>::encoding() <= 0).
>How-To-Repeat:
See attachment.
>Fix:

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

#include <fstream>
#include <locale>

#undef NDEBUG
#include <cassert>

int main()
{
	using namespace std;

	wfilebuf fb;
	fb.pubimbue(locale("is_IS.UTF-8"));
	fb.open("setposbug.cc", ios_base::in);
	fb.sbumpc();
	streampos p1 = fb.pubseekoff(0, ios_base::cur);
	fb.sbumpc();
	streampos p2 = fb.pubseekpos(p1);
	assert(p2 != streampos(-1));
	fb.close();

	return 0;
}



More information about the Gcc-bugs mailing list