[LLVMbugs] [Bug 11752] New: ifstream - reopening a file does not see the beginning.

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Jan 12 13:31:07 PST 2012


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

             Bug #: 11752
           Summary: ifstream - reopening a file does not see the
                    beginning.
           Product: libc++
           Version: unspecified
          Platform: Macintosh
        OS/Version: MacOS X
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
        AssignedTo: hhinnant at apple.com
        ReportedBy: ohsumit at molbio.mgh.harvard.edu
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified


Created attachment 7871
  --> http://llvm.org/bugs/attachment.cgi?id=7871
The test program

Hello.  I tried this both on the latest Xcode (4.2.1) for Mac OS X, as well as
what I built under Linux and similar results occurred.  Specifically, please
check out the included program that opens the test file test.txt that just has
strings line1, line2, and line3 on 3 lines.  The first time, the program opens
it and prints the first two lines, everything is fine.  The second time, even
though I even tried seekg'ing back to the beginning (shouldn't have to), it
still reads the last line first.  The commands I used are attached below. 
Notice how it works fine when I do *not* include -stdlib=c++. Note all the
below commands were done on my Mac OS X Lion. Any help would be most
appreciated.  Many thanks,


        - Toshi

------------------ commands ---------------


bash-3.2$ cat test.txt
line1
line2
line3
bash-3.2$ clang++ --version
Apple clang version 3.0 (tags/Apple/clang-211.12) (based on LLVM 3.0svn)
Target: x86_64-apple-darwin11.2.0
Thread model: posix
bash-3.2$ clang++ -stdlib=libc++ test.cpp
bash-3.2$ ./a.out
Round 1:
first line = line1
second line = line2
Round 2:
first line = line3
second line = line1
bash-3.2$ clang++ test.cpp
bash-3.2$ ./a.out
Round 1:
first line = line1
second line = line2
Round 2:
first line = line1
second line = line2

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