[llvm-bugs] [Bug 46729] New: Clang accepts template specialization in C linkage
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jul 15 07:47:45 PDT 2020
https://bugs.llvm.org/show_bug.cgi?id=46729
Bug ID: 46729
Summary: Clang accepts template specialization in C linkage
Product: clang
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Frontend
Assignee: unassignedclangbugs at nondot.org
Reporter: haoxintu at gmail.com
CC: llvm-bugs at lists.llvm.org, neeilans at live.com,
richard-llvm at metafoo.co.uk
Hi, all.
This code, test.cc, I am sure it's an invalid code but Clang compiles it well.
$cat test.cc
template <class> void F(){};
extern "C" {
template < >
void F<int>();
}
While in other compilers I tested:
Output in GCC:
test.cc:3:5: error: template specialization with C linkage
3 | template < >
| ^~~~~~~~
test.cc:2:1: note: 'extern "C"' linkage started here
2 | extern "C" {
| ^~~~~~~~~~
Output in ICC:
test.cc(3): error: this declaration may not have extern "C" linkage
template < >
^
Output in MSVC:
test.cc(3): error C2894: templates cannot be declared to have 'C' linkage
Interestingly, every Clang version from 5.0 onwards behaves the same, only
clang-4.0 rejects this.
Thanks,
Haoxin
--
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/20200715/64ec3856/attachment.html>
More information about the llvm-bugs
mailing list