This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/11389] New: Unbuffered wfilebuf fails to read single-byte UTF-8 characters.


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.


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