wctomb dumps core on invalid input
Ulrich Drepper
drepper@redhat.com
Mon Dec 4 15:43:00 GMT 2000
Bruno Haible <haible@ilog.fr> writes:
> According to SUSV2, "wctomb() returns -1 if the value of wchar does not
> correspond to a valid character". This is not what glibc 2.2 does. Here
> is a test program.
>
> ===========================================
> #include <wchar.h>
> #include <locale.h>
>
> int main ()
> {
> char buf[10];
> wchar_t wc = 0xdeadbeef;
There's a difference. The standard text refers to the character in
the multibyte encoding. If there is no equivalent to the wide
character -1 is returned.
A value like 0xdeadbeef for a wchar_t is completely impossible to get
since no module can produce it. The assumption that values of wchar_t
are <= 0x7fffffff must always be met.
--
---------------. ,-. 1325 Chesapeake Terrace
Ulrich Drepper \ ,-------------------' \ Sunnyvale, CA 94089 USA
Red Hat `--' drepper at redhat.com `------------------------
More information about the Libc-alpha
mailing list