<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 --- - getline does not split lines after istream.imbue"
   href="http://llvm.org/bugs/show_bug.cgi?id=17171">17171</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>getline does not split lines after istream.imbue
          </td>
        </tr>

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

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

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </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>4c37f23e53a3@7db1b5ea0a98.anonbox.net
          </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>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;
}</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>