[LLVMbugs] [Bug 17537] New: Explicit specialization of deleted function template not possible

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Thu Oct 10 12:16:00 PDT 2013


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

            Bug ID: 17537
           Summary: Explicit specialization of deleted function template
                    not possible
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++11
          Assignee: unassignedclangbugs at nondot.org
          Reporter: jonathan.sauer at gmx.de
                CC: dgregor at apple.com, llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The following code fails to compile with clang r192096:

template <typename T>
void foo() = delete;

template <>
void foo<int>()
{
}

int main()
{
    foo<int>();
}


This results in:

% ~/LLVM/build/Release+Asserts/bin/clang++ -std=c++11 clang.cpp
clang.cpp:5:6: error: redefinition of 'foo'
void foo<int>()
     ^
clang.cpp:5:6: note: previous definition is here
clang.cpp:11:5: error: no matching function for call to 'foo'
    foo<int>();
    ^~~~~~~~
clang.cpp:2:6: note: candidate template ignored: substitution failure [with T =
int]
void foo() = delete;
     ^
2 errors generated.


According to ยง14.7.3p1 [temp.expl.spec], it should be allowed to delete a
function template while explicitly specializing it for a few types. This was
introduced by DR941:

| According to 14.7.3 [temp.expl.spec] paragraph 1, only non-deleted function
| templates may be explicitly specialized. There doesn't appear to be a
compelling
| need for this restriction, however, and it could be useful to forbid use of
| implicitly-instantiated specializations while still allowing use of
explicitly-
| specialized versions.

<http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#941>

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


More information about the llvm-bugs mailing list