public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* libstdc++/9870: ctype<wchar_t>::do_widen(char) is broken
@ 2003-02-27  3:36 jon
  0 siblings, 0 replies; only message in thread
From: jon @ 2003-02-27  3:36 UTC (permalink / raw)
  To: gcc-gnats


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


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

only message in thread, other threads:[~2003-02-27  3:36 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-27  3:36 libstdc++/9870: ctype<wchar_t>::do_widen(char) is broken jon

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).