https://bugs.llvm.org/show_bug.cgi?id=46728

            Bug ID: 46728
           Summary: Clang accepts explicit specialization in class
                    definition
           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, 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".

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