<html>
    <head>
      <base href="https://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 --- - libc++ defines getline(istream, string) in <istream> instead of <string>"
   href="https://llvm.org/bugs/show_bug.cgi?id=25232">25232</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>libc++ defines getline(istream, string) in <istream> instead of <string>
          </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>All
          </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>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>nicolasweber@gmx.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, mclow.lists@gmail.com
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>This doesn't link:

$ cat test.cc
#include <iosfwd>
#include <string>

std::string f(std::istream& is) {
  std::string s;
  std::getline(is, s);
  return s;
}
$ clang++ -shared test.cc -o libfoo.so
Undefined symbols for architecture x86_64:
  "std::__1::basic_istream<char, std::__1::char_traits<char> >&
std::__1::getline<char, std::__1::char_traits<char>, std::__1::allocator<char>
<span class="quote">>(std::__1::basic_istream<char, std::__1::char_traits<char> >&,</span >
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >&)", referenced from:
      f(std::__1::basic_istream<char, std::__1::char_traits<char> >&) in
test-935a1a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

<a href="http://en.cppreference.com/w/cpp/string/basic_string/getline">http://en.cppreference.com/w/cpp/string/basic_string/getline</a> says that this
function should be in <string>. In libc++, it's declared in <string> but
defined in <istream>. If I add an `#include <istream>` to the file above, it
links fine.

<a class="bz_bug_link 
          bz_status_RESOLVED  bz_closed"
   title="RESOLVED FIXED - Define std::getline in <string>, not <istream>"
   href="show_bug.cgi?id=10390">Bug 10390</a> added the declarations to <string>, but it seems that the definition
should be there too?


(I kind of feel that I filed this before and that someone explained to me why
this things are arguably correct as they are now, but I can't find anything
like that.)</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>