Bug 9521 - Garbled input from wcin
Summary: Garbled input from wcin
Status: RESOLVED DUPLICATE of bug 9520
Alias: None
Product: gcc
Classification: Unclassified
Component: libstdc++ (show other bugs)
Version: 3.2.1
: P3 normal
Target Milestone: ---
Assignee: Paolo Carlini
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-01-31 12:16 UTC by Pétur Runólfsson
Modified: 2003-06-12 00:15 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
ungetcbug.cc (394 bytes, application/octet-stream)
2003-05-21 15:17 UTC, Pétur Runólfsson
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Pétur Runólfsson 2003-01-31 12:16:01 UTC
If wcin.rdbuf()->sgetc() is called followed by wcin.rdbuf()->sbumpc(), the return value is not always the same, unless the charset in use happens to be ISO-8859-1.

Reason: basic_filebuf<wchar_t>::_M_underflow_common returns wide characters to the FILE* using ungetc. This happens to work if the charset is ISO-8859-1 (because the values are the same as in UCS-4), but breaks for all other single-byte charsets.

Note that there is an even more serious bug here when dealing with multibyte charsets: in general a single wide character can have been converted from more than one narrow character. This is however shadowed by other problems in _M_underflow_common.

Release:
gcc-3.2.1

Environment:
Red Hat Linux 8.0

How-To-Repeat:
See attachment.
Comment 1 Paolo Carlini 2003-01-31 13:28:55 UTC
*** This bug has been marked as a duplicate of 9520 ***
Comment 2 Pétur Runólfsson 2003-01-31 13:30:59 UTC
From: =?iso-8859-1?Q?P=E9tur_Run=F3lfsson?= <peturr02@ru.is>
To: <paolo@gcc.gnu.org>,
	<gcc-bugs@gcc.gnu.org>,
	<gcc-prs@gcc.gnu.org>,
	<nobody@gcc.gnu.org>,
	<gcc-gnats@gcc.gnu.org>
Cc:  
Subject: RE: libstdc++/9521: Garbled input from wcin
Date: Fri, 31 Jan 2003 13:30:59 -0000

 > Synopsis: Garbled input from wcin
 >=20
 > State-Changed-From-To: open->closed
 > State-Changed-By: paolo
 > State-Changed-When: Fri Jan 31 13:28:55 2003
 > State-Changed-Why:
 >     Exact duplicate of libstdc++/9520.
 >=20
 > http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=3Dview%20audit-trail&
 database=3Dgcc&pr=3D9521
 
 Yup, sorry about that. Must have hit submit twice :-(
 
 Petur