libstdc++/9247: codecvt<wchar_t, char, mbstate_t> does not return partial if output buffer too small
peturr02@ru.is
peturr02@ru.is
Mon Jan 13 05:17:00 GMT 2003
>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;
}
More information about the Gcc-bugs
mailing list