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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to