<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 --- - istream getline sets eof prematurely"
   href="http://llvm.org/bugs/show_bug.cgi?id=16162">16162</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>istream getline sets eof prematurely
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>hhinnant@apple.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>stephan.bergmann.secondary@googlemail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>At least on Mac OS X 10.7.5 with Xcode 4.6.2 (clang --version "Apple LLVM
version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)"), libc++ getline sets
eofbit already when it reads a delim-terminated line that will be followed by
eof (which getline should not yet inspect, according to [istream.unformatted]
in both the C++03 and C++11 standards).  That is, with a test.cc

<span class="quote">> #include <cstdlib>
> #include <iostream>

> int main() {
>     char b[100];
>     std::cin.getline(b, sizeof b);
>     return std::cin.eof() ? EXIT_FAILURE : EXIT_SUCCESS;
> }</span >

and a Makefile

<span class="quote">> .PHONY: TEST1 TEST2

> TEST1: test1 oneline
>    ./test1 <oneline

> TEST2: test2 oneline
>    ./test2 <oneline

> test1: test.cc
>    clang++ -stdlib=libc++ test.cc -o $@

> test2: test.cc
>    clang++ test.cc -o $@

> oneline:
>    printf 'oneline\n' >$@</span >

"make TEST1" fails while "make TEST2" (using libstdc++ instead) succeeds.</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>