Martin
Martin

Reputation: 9359

Member template specialization does not compile with clang

Consider the following program:

struct S {
    enum E {
        e
    };
    template<E> void f() = delete;
};

template<> void S::f<S::E::e>() {}

int main() {
    S s;
    s.f<S::E::e>();
}

GCC 5.4.0 compiles the code, while clang 3.8.0 fails:

$ clang++ -std=c++14 main.cpp 
main.cpp:10:20: error: redefinition of 'f'
template<> void S::f<S::E::e>() {
                   ^
main.cpp:8:20: note: previous definition is here
template<> void S::f<S::E::e>();
                   ^
main.cpp:14:11: error: no matching member function for call to 'f'
        s.f<S::E::e>();
        ~~^~~~~~~~~~
main.cpp:5:22: note: candidate template ignored: substitution failure [with $0 = S::E::e]
    template<E> void f() = delete;
                     ^
2 errors generated.

Is clang correct and GCC wrong or is it the opposite? Note that if the delete specifier is removed, then clang compiles the code.

Upvotes: 2

Views: 171

Answers (1)

Massimiliano Janes
Massimiliano Janes

Reputation: 5624

this seems defect report Explicit specialization of deleted function template , as you can see from here the issue seems fixed in clang since 3.9.0.

Upvotes: 1

Related Questions