This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
libstdc++/9870: ctype<wchar_t>::do_widen(char) is broken
- From: jon at biggar dot org
- To: gcc-gnats at gcc dot gnu dot org
- Date: 27 Feb 2003 03:32:10 -0000
- Subject: libstdc++/9870: ctype<wchar_t>::do_widen(char) is broken
- Reply-to: jon at biggar dot org
>Number: 9870
>Category: libstdc++
>Synopsis: ctype<wchar_t>::do_widen(char) is broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Feb 27 03:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Jonathan Biggar
>Release: gcc 3.2
>Organization:
>Environment:
>Description:
The current implementation of ctype<wchar_t>::do_widen(char)
is broken, because it uses btowc. The glibc man page for
btowc already states that this function should never be used
because it doesn't handle stateful or multibyte character
encodings well.
Also, since btowc takes an int argument, calling it with a
char value on machines that use signed char improperly sign
extends the argument, which causes an incorrect result to
be returned.
For example, calling do_widen(0xFF) in an ISO8859-1 locale
returns -1, rather than the correct 0xFF.
>How-To-Repeat:
call do_widen() with a signed char value between 0x80 and
0xFF.
>Fix:
do_widen(char) should use mbsrtowcs, like the array based
version does.
>Release-Note:
>Audit-Trail:
>Unformatted: