Date: Mon, 02 Jul 2018 21:18:26 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 229479] clang unused code triggers link failure Message-ID: <bug-229479-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D229479 Bug ID: 229479 Summary: clang unused code triggers link failure Product: Base System Version: 11.2-STABLE Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: adridg@freebsd.org With 11.2-STABLE, using either base clang or clang50 from ports, this C++ program compiles, but fails to link: ``` #include <string> static std::string foop() { return std::string(); } int main() { (void)(foop); return 0; } ``` The error message is ``` [adridg@beastie]$ c++ t.cpp=20 /tmp/t-0b5183.o: In function `foop()': t.cpp:(.text+0x20): undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::basic_string()' /usr/bin/ld: a.out: hidden symbol `_ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEC2Ev' isn't defined /usr/bin/ld: final link failed: Nonrepresentable section on output ``` The same problem occurs with clang50 on 11-STABLE, and with (base) clang60 = on 12-CURRENT from mid-june. The program compiles and links without issue with g++6 on 11-STABLE. Removing the line `(void)(foop);` allows the program to link; it does gener= ate one warning about an unused function, though. **On Linux**: The program compiles and links with clang5 and clang6 on Linux using the default C++ library (e.g. `clang++ t.cpp`). I am told that it does **not** link when using libc++ (e.g. `clang++ -stdlib=3Dlibc++ t.cpp`). I h= ave not been able to verify that, though --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-229479-227>