-
Notifications
You must be signed in to change notification settings - Fork 14.5k
Closed
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Description
Bugzilla Link | 25232 |
Version | unspecified |
OS | All |
CC | @mclow |
Extended Description
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> >(std::__1::basic_istream<char, std::__1::char_traits<char> >&, 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)
http://en.cppreference.com/w/cpp/string/basic_string/getline 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.
Bug 10390 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.)
Metadata
Metadata
Assignees
Labels
bugzillaIssues migrated from bugzillaIssues migrated from bugzillalibc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.