[LLVMbugs] [Bug 17171] New: getline does not split lines after istream.imbue

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Sep 9 11:43:53 PDT 2013


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

            Bug ID: 17171
           Summary: getline does not split lines after istream.imbue
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: hhinnant at apple.com
          Reporter: 4c37f23e53a3 at 7db1b5ea0a98.anonbox.net
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

When trying to read a unicode file, std::getline does not find newlines, i.e.,
something is broken when using std::getline after input.imbue(locale).

The code below should output "2 == 2", and it does so for libstdc++. libcxx
however ignores the newline and has the output "2 == 1", unless the newline
character is specified by hand.

Note that the deactivated part (#if 0) has the same problem, when the locale is
utf8.

#include <iostream>
#include <locale>
#include <sstream>
#include <string>

int main()
{
#if 0
 std::locale locale("");
 auto& input=std::wcin;
#else
 std::locale locale("en_US.utf8");
 std::wistringstream input(L"abc\r\nbca\r\n");
#endif
 input.imbue(locale);

 int count=0;
 for(std::wstring s;std::getline(input,s /*,L'\n'*/ );++count);
 std::cout << "2 == " << count << std::endl;
 return count;
}

-- 
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/20130909/18044249/attachment.html>


More information about the llvm-bugs mailing list