This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/11389] New: Unbuffered wfilebuf fails to read single-byte UTF-8 characters.
- From: "peturr02 at ru dot is" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Jul 2003 09:20:24 -0000
- Subject: [Bug libstdc++/11389] New: Unbuffered wfilebuf fails to read single-byte UTF-8 characters.
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11389
Summary: Unbuffered wfilebuf fails to read single-byte UTF-8
characters.
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: libstdc++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: peturr02 at ru dot is
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
When using a variable-width character set, but reading a file that contains only
single-byte characters from that character set, basic_filebuf::underflow reads
more bytes than can be converted and placed in the internal buffer:
const streamsize __blen = __buflen * _M_codecvt->max_length();
char* __buf = static_cast<char*>(__builtin_alloca(__blen));
__elen = _M_file.xsgetn(__buf, __blen);
If the file contains only single byte characters, only __buflen bytes need to be
read to fill the internal buffer. It seems that the extra characters read are
discarded.