<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Link error with __attribute__((target)) and inline"
href="https://bugs.llvm.org/show_bug.cgi?id=51509">51509</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Link error with __attribute__((target)) and inline
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>12.0
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>C++
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>duvan.llvm@gmail.com
</td>
</tr>
<tr>
<th>CC</th>
<td>blitzrakete@gmail.com, dgregor@apple.com, erik.pilkington@gmail.com, llvm-bugs@lists.llvm.org, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=25149" name="attach_25149" title="Reproducer">attachment 25149</a> <a href="attachment.cgi?id=25149&action=edit" title="Reproducer">[details]</a></span>
Reproducer
The following code (also in bug.C) fails to link:
#include <iostream>
#include <string>
__attribute__((target("default"))) inline std::string target() { return
"default"; }
int main() {
std::cout << target() << std::endl;
}
bash> clang++ bug.C -o bug
Undefined symbols for architecture x86_64:
"std::__1::basic_string<char, std::__1::char_traits<char>,
std::__1::allocator<char> >::basic_string<std::__1::nullptr_t>(char const*)",
referenced from:
target() in bug-b35498.o
ld: symbol(s) not found for architecture x86_64
If either removing the inline keyword or the __attribute__((target("default"))
it links again.
clang++ -v
Apple clang version 12.0.5 (clang-1205.0.22.11)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
I get the same problem on a Linux machine with a clang 12.0 that I built from
sources and which is using libstdc++ from gcc 11.1 via the --gcc-toolchain
switch.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>