[llvm-bugs] [Bug 51509] New: Link error with __attribute__((target)) and inline
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue Aug 17 08:18:29 PDT 2021
https://bugs.llvm.org/show_bug.cgi?id=51509
Bug ID: 51509
Summary: Link error with __attribute__((target)) and inline
Product: clang
Version: 12.0
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: duvan.llvm at gmail.com
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
Created attachment 25149
--> https://bugs.llvm.org/attachment.cgi?id=25149&action=edit
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.
--
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/20210817/bd2a6b12/attachment.html>
More information about the llvm-bugs
mailing list