[LLVMbugs] [Bug 13602] New: basic_filebuf's internal buffer is shrinking when using with some codecvt.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Aug 14 02:59:52 PDT 2012


http://llvm.org/bugs/show_bug.cgi?id=13602

             Bug #: 13602
           Summary: basic_filebuf's internal buffer is shrinking when
                    using with some codecvt.
           Product: libc++
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
        AssignedTo: hhinnant at apple.com
        ReportedBy: tuhertz at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


When I replace the codecvt in fstream with my custom codecvt which is
converting char to char32_t, internal representation buffer size keep
shrinking. 

In fstream header file, underflow() call fread with egptr()-eback() as buffer
size and call codecvt->in() with egptr() as buffer end. Because internal
representation can be fewer characters than external representation, so
calculating read size by egptr() result in buffer shrinking. It should be
replace by __ibs_ and eback()+__ibs_ respectively.

line 594
size_t __nmemb = _VSTD::min(static_cast<size_t>(this->egptr() - this->eback() -
__unget_sz), static_cast<size_t>(__extbufend_ - __extbufnext_));

this->egptr() - this->back() should be replaced by __ibs_

line 603
 __r = __cv_->in(__st_, __extbuf_, __extbufend_, __extbufnext_,
                                       this->eback() + __unget_sz,
                                       this->egptr(), __inext);

this->egptr() need to be replaced by this->eback() + __ibs_

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list