[llvm-bugs] [Bug 25232] New: libc++ defines getline(istream, string) in <istream> instead of <string>

via llvm-bugs llvm-bugs at lists.llvm.org
Sat Oct 17 21:48:26 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=25232

            Bug ID: 25232
           Summary: libc++ defines getline(istream, string) in <istream>
                    instead of <string>
           Product: libc++
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com
    Classification: Unclassified

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.)

-- 
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/20151018/c2f99b97/attachment.html>


More information about the llvm-bugs mailing list