http://llvm.org/bugs/show_bug.cgi?id=22670

            Bug ID: 22670
           Summary: explicit specialization declarations don't work if
                    they appear after the template-id is mentioned
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected]
    Classification: Unclassified

Consider:

template<int> struct A {};
typedef A<1> A1;
template<> struct A<1>;                                         
void f() { delete (A1*)0; }
template<> struct A<1> {};

Clang rejects this saying:

<stdin>:5:19: error: redefinition of 'A<1>'
template<> struct A<1> {};
                  ^~~~
<stdin>:1:22: note: previous definition is here
template<int> struct A {};
                     ^

But that's wrong: we should not have instantiated A<1> from the primary
template because we have a declaration of an explicit specialization for A<1>.
Instead, we should have treated the delete-expression as deleting an incomplete
type.

Creating the template-id A<1> should not cause the implicit instantiation of
A<1>, so we are not required to first declare the explicit specialization. And
even if we were incorrectly doing so, we should instead diagnose this as:

<stdin>:3:19: error: explicit specialization of 'A<1>' after instantiation
template<> struct A<1>;
                  ^~~~
<stdin>:2:9: note: implicit instantiation first required here
typedef A<1> A1;
        ^

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to