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: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    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.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to