[LLVMbugs] [Bug 19497] New: std::ws sets failbit at eof

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Apr 21 01:55:03 PDT 2014


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

            Bug ID: 19497
           Summary: std::ws sets failbit at eof
           Product: libc++
           Version: 3.3
          Hardware: PC
                OS: FreeBSD
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: shurd at sasktel.net
                CC: llvmbugs at cs.uiuc.edu, mclow.lists at gmail.com
    Classification: Unclassified

When porting an application recently, I discovered that std::ws sets the
failbit if it is called when eofbit is set.  This differs from the libstdc++
behaviour and there's a StackOverflow mention of it here:
http://stackoverflow.com/questions/13423514/should-stdws-raise-failbit-at-end-of-file

#include <iostream>
#include <sstream>
using namespace std;

int main(int argc, char **argv)
{
        int i;
        stringstream s("0");
        s >> i >> std::ws;
        cout << "eof: " << s.eof() << " fail: " << s.fail() << "\n";
        return 0;
}


Output (c++ is FreeBSD Clang 3.3 and g++47 is GNU C++ 4.7):
> c++ test.cpp 
> ./a.out 
eof: 1 fail: 1
> g++47 test.cpp 
> ./a.out
eof: 1 fail: 0

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20140421/9b71acfd/attachment.html>


More information about the llvm-bugs mailing list