2

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.

Barry
  • 286,269
  • 29
  • 621
  • 977
Martin
  • 9,089
  • 11
  • 52
  • 87

1 Answers1

1

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.

Massimiliano Janes
  • 5,524
  • 1
  • 10
  • 22