public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libstdc++/9247: codecvt<wchar_t, char, mbstate_t> does not return partial if output buffer too small
@ 2003-01-09 16:06 peturr02
  0 siblings, 0 replies; only message in thread
From: peturr02 @ 2003-01-09 16:06 UTC (permalink / raw)
  To: gcc-gnats


>Number:         9247
>Category:       libstdc++
>Synopsis:       codecvt<wchar_t, char, mbstate_t> does not return partial if output buffer too small
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jan 09 08: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:
If codecvt<wchar_t, char, mbstate_t> is passed an output buffer that is too small to hold the result of the conversion, but the conversion otherwise succeeds, ok is returned instead of partial.
>How-To-Repeat:
See attachment.
>Fix:

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

#include <locale>

int main()
{
	using namespace std;
	typedef codecvt<wchar_t, char, mbstate_t> w_codecvt;

	locale loc;
	w_codecvt const& cvt = use_facet<w_codecvt>(loc);

	char const source[] = "abcdefghijklmnopqrstuvwxyz";
	size_t size = sizeof(source) - 1;

	char const* from_next;
	wchar_t buffer[1024];
	wchar_t* to_next;

	mbstate_t state;
	memset(&state, 0, sizeof(state));

	codecvt_base::result res = cvt.in(state, source, source + size,
					  from_next, buffer, buffer + 1,
					  to_next);
	if (res == codecvt_base::ok)
		assert(from_next == source + size);

	return 0;
}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-01-09 16:06 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-09 16:06 libstdc++/9247: codecvt<wchar_t, char, mbstate_t> does not return partial if output buffer too small 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).