[LLVMbugs] [Bug 13089] New: istream::seekg(pos_type) does not clear eofbit

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Jun 11 21:04:02 PDT 2012


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

             Bug #: 13089
           Summary: istream::seekg(pos_type) does not clear eofbit
           Product: libc++
           Version: unspecified
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
        AssignedTo: hhinnant at apple.com
        ReportedBy: cubbimew at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


In C++11, ยง27.7.2.3[istream.unformatted]/41 says

basic_istream<charT,traits>& seekg(pos_type pos);

Effects: Behaves as an unformatted input function (as described in 27.7.2.3,
paragraph 1), except that the function first clears eofbit

In libc++, seekg() goes straight into sentry object construction:

basic_istream<_CharT, _Traits>::seekg(pos_type __pos)
{
#ifndef _LIBCPP_NO_EXCEPTIONS
    try
    {
#endif  // _LIBCPP_NO_EXCEPTIONS
        sentry __sen(*this, true);

Testcase:

#include <sstream>
#include <iostream>

int main()
{
    std::istringstream buf("test");
    std::string s;
    std::getline(buf, s); // buf.eof() == true
    buf.seekg(1);         // should work
    std::cout << "eof = " << buf.eof() << " fail= " << buf.fail() << '\n';
}

expected output: "eof = 0 fail= 0"
observed: "eof = 1 fail= 1"

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