<html>
    <head>
      <base href="http://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - std::ws sets failbit at eof"
   href="http://llvm.org/bugs/show_bug.cgi?id=19497">19497</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>std::ws sets failbit at eof
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libc++
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.3
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>FreeBSD
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>All Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>shurd@sasktel.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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:
<a href="http://stackoverflow.com/questions/13423514/should-stdws-raise-failbit-at-end-of-file">http://stackoverflow.com/questions/13423514/should-stdws-raise-failbit-at-end-of-file</a>

#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):
<span class="quote">> c++ test.cpp 
> ./a.out </span >
eof: 1 fail: 1
<span class="quote">> g++47 test.cpp 
> ./a.out</span >
eof: 1 fail: 0</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>