[Bug 229479] clang unused code triggers link failure
bugzilla-noreply at freebsd.org
bugzilla-noreply at freebsd.org
Mon Jul 2 21:18:28 UTC 2018
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=229479
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 at FreeBSD.org
Reporter: adridg at 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 at beastie]$ c++ t.cpp
/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 generate
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=libc++ t.cpp`). I have
not been able to verify that, though
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the freebsd-bugs
mailing list