[LLVMbugs] [Bug 22670] New: explicit specialization declarations don't work if they appear after the template-id is mentioned

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 23 18:13:02 PST 2015


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: unassignedclangbugs at nondot.org
          Reporter: richard-llvm at metafoo.co.uk
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150224/b37b8919/attachment.html>


More information about the llvm-bugs mailing list