[LLVMbugs] [Bug 17671] New: link error when passing &std::string::empty to std::bind()
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Oct 23 22:41:23 PDT 2013
http://llvm.org/bugs/show_bug.cgi?id=17671
Bug ID: 17671
Summary: link error when passing &std::string::empty to
std::bind()
Product: libc++
Version: unspecified
Hardware: Macintosh
OS: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: All Bugs
Assignee: hhinnant at apple.com
Reporter: arvid.norberg at gmail.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
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).
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20131024/35a3df9f/attachment.html>
More information about the llvm-bugs
mailing list