[LLVMbugs] [Bug 16162] New: istream getline sets eof prematurely

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 28 07:38:25 PDT 2013


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

            Bug ID: 16162
           Summary: istream getline sets eof prematurely
           Product: libc++
           Version: unspecified
          Hardware: Macintosh
                OS: MacOS X
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: stephan.bergmann.secondary at googlemail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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

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

and a Makefile

> .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' >$@

"make TEST1" fails while "make TEST2" (using libstdc++ instead) succeeds.

-- 
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/20130528/3ab0e54d/attachment.html>


More information about the llvm-bugs mailing list