<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 --- - Linker errors on std::getline when including only <string> and not <istream>"
href="http://llvm.org/bugs/show_bug.cgi?id=20960">20960</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Linker errors on std::getline when including only <string> and not <istream>
</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>pbos@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu, mclow.lists@gmail.com
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>I believe this is in current ToT, we saw errors within a month in webrtc
requiring us to include <istream> in chromium.
We use a library that accepts istreams and uses getline, it doesn't define any
istreams itself so it didn't have to include istream but rather accept
references provided externally.
As getline seems to be instantiated in istream in libc++ this causes linker
errors:
#include <string>
std::istream& foo_getline(std::istream& is, std::string& str, char delim) {
return std::getline(is, str, delim);
}
int main() {
std::string foo;
// expecting runtime crash not linker error
foo_getline(*(std::istream*)(NULL), foo, ' ');
}
$ clang++ --stdlib=libc++ foo.cc
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> >&, char)", referenced from:
foo_getline(std::__1::basic_istream<char, std::__1::char_traits<char> >&,
std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >&, char) in foo-ATxcEi.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This invocation is on a colleague's MacBook Pro, unknown version. We did see
this in r216548 in webrtc last I checked and had to use a workaround, so I
believe it's still present.</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>