[llvm-bugs] [Bug 46728] New: Clang accepts explicit specialization in class definition

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Jul 15 07:40:20 PDT 2020


            Bug ID: 46728
           Summary: Clang accepts explicit specialization in class
           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, is an invalid code I guess, but Clang accepts this without
any diagnostic message.

$cat test.cc
class A {
    template <class> void F(){};
    template <> void F<int>(); 

I think explicit specialization shouldn't exist in a class definition.

While in other compilers:

Output in GCC:
test.cc:3:15: error: explicit specialization in non-namespace scope 'class A'
    3 |     template <> void F<int>();
      |               ^
test.cc:3:22: error: template-id 'F<int>' in declaration of primary template
    3 |     template <> void F<int>();
      |                      ^~~~~~

Output in ICC:
test.cc: error: explicit specialization is not allowed in the current scope
      template <> void F<int>(); 

Noted that this issue only happens in Clang-7 and onwards version, while other
version upwards Clang-6 rejects this with "error: explicit specialization of
'F' in class scope".


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/e7c829a9/attachment.html>

More information about the llvm-bugs mailing list