<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 --- - link error when passing &std::string::empty to std::bind()"
href="http://llvm.org/bugs/show_bug.cgi?id=17671">17671</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>link error when passing &std::string::empty to std::bind()
</td>
</tr>
<tr>
<th>Product</th>
<td>libc++
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>Macintosh
</td>
</tr>
<tr>
<th>OS</th>
<td>MacOS X
</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>arvid.norberg@gmail.com
</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 using the clang++ shipped with maverick:
$ clang++ --version
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
Compiling the following test program:
$ cat test.cpp
#include <string>
#include <functional>
int main()
{
using namespace std::placeholders;
auto b = std::bind(&std::string::empty, _1);
}
yields the following linker error (including verbose output):
$ clang++ -std=c++11 -stdlib=libc++ test.cpp -v
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang"
-cc1 -triple x86_64-apple-macosx10.9.0 -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name test.cpp -mrelocation-model pic
-pic-level 2 -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu core2
-target-linker-version 224.1 -v -resource-dir
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0
-stdlib=libc++ -std=c++11 -fdeprecated-macro -fdebug-compilation-dir
/Volumes/Macintosh_HD/Users/arvid/Documents/dev/libtorrent_repo/branches/libtorrent_aio/examples
-ferror-limit 19 -fmessage-length 422 -stack-protector 1 -mstackrealign
-fblocks -fobjc-runtime=macosx-10.9.0 -fobjc-dispatch-method=mixed
-fobjc-default-synthesize-properties -fencode-extended-block-signature
-fcxx-exceptions -fexceptions -fdiagnostics-show-option -fcolor-diagnostics -o
/var/folders/5t/_1409vt96r32fdwrf88ttj5h0000gn/T/test-gDiqkt.o -x c++ test.cpp
clang -cc1 version 5.0 based upon LLVM 3.3svn default target
x86_64-apple-darwin13.0.0
ignoring nonexistent directory "/usr/include/c++/v1"
#include "..." search starts here:
#include <...> search starts here:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1
/usr/local/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/include
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
/usr/include
/System/Library/Frameworks (framework directory)
/Library/Frameworks (framework directory)
End of search list.
"/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld"
-demangle -dynamic -arch x86_64 -macosx_version_min 10.9.0 -o a.out
/var/folders/5t/_1409vt96r32fdwrf88ttj5h0000gn/T/test-gDiqkt.o -lc++ -lSystem
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.0/lib/darwin/libclang_rt.osx.a
Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::empty() const", referenced from:
_main in test-gDiqkt.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I discovered this using boost::bind(&std::string::empty, /* ... */ ) building
in C++98 mode. Since it reproduces with std::bind as well, that makes for a
smaller test case.
If I explicitly link with libstdc++, it works (in c++98 mode, using
boost::bind):
$ cat test.cpp
#include <string>
#include <boost/bind.hpp>
int main()
{
boost::bind(&std::string::empty, _1);
}
$ clang++ test.cpp -I ~/Documents/dev/boost_1_53_0
Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::empty() const", referenced from:
_main in test-6JWhFO.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ clang++ test.cpp -I ~/Documents/dev/boost_1_53_0 -stdlib=libstdc++
(success)
This may be old news, but with maverick apparently switching to libc++ as the
default, this was exposed.
I don't know how to find out what version of libc++ I have installed, but it
should be what is shipped with the latest xcode for maverick (unless something
went terribly wrong in the upgrade process).</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>