This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: wctomb dumps core on invalid input


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   `------------------------

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