关于显式实例化和显式特化顺序的问题

A issue about the order of explicit instantiation and explicit specialization

#include <iostream>
template<typename T>
void func(T){}

template void func<int>(int);

template<>
void func<int>(int){

}
int main(){

}

考虑上面的代码,ClangGCC 都抱怨这样的代码是 ill-formed,如下所示。

explicit specialization of 'func<int>' after instantiation

但是,我只找到类似的规则:
temp.expl.spec#6

If a template, a member template or a member of a class template is explicitly specialized then that specialization shall be declared before the first use of that specialization that would cause an implicit instantiation to take place, in every translation unit in which such a use occurs; no diagnostic is required. If the program does not provide a definition for an explicit specialization and either the specialization is used in a way that would cause an implicit instantiation to take place or the member is a virtual member function, the program is ill-formed, no diagnostic required. An implicit instantiation is never generated for an explicit specialization that is declared but not defined.

我认为这样的代码不违反上面的规则,注意强调的部分,它说implicit instantiation,在我的例子中,这样的声明template void func<int>(int);是一个显式实例化定义而不是特化会导致隐式实例化,那么为什么上面的代码格式错误?上述代码违反了标准中的什么规则?请指出规则。谢谢。

有点零散,不过这里的相关规则是[temp.spec]/5

For a given template and a given set of template-arguments, [...]

  • both an explicit instantiation and a declaration of an explicit specialization shall not appear in a program unless the explicit instantiation follows a declaration of the explicit specialization. [...]