https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102042
Bug ID: 102042 Summary: specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: nickhuang99 at hotmail dot com Target Milestone: --- I suspect this is from similar root cause of PR101402, PR102033, PR102034 etc. when incorrectly dropping top-level cv-qualifier during calculating template function declarator of which parameter is an array of template function pointer. Clearly from "#2" of static assert, GCC already gets correct specialization "g<1,int>" signature, still the last statement of specialization declaration causes error with very strange error message. clang(https://www.godbolt.org/z/5eM5b4GjG) accepts. MSVC++(https://www.godbolt.org/z/3x9dvsfTh) stumbles like GCC, but a better clear clue. #include<type_traits> template<unsigned int N, class T> void f(const T[N]){} template<unsigned int N, class T> using fPtr=decltype(f<N,T>)*; template<unsigned int N, class T> fPtr<N,T> af[N]={&f<N,T>}; // even without initialization,error still is template<unsigned int N, class T> void g(const decltype(af<N,T>)&){} static_assert(std::is_same<decltype(af<1,int>), fPtr<1,int>[1] >::value, "af is correct"); // #1 static_assert(std::is_same<decltype(g<1,int>), void(fPtr<1,int>const(&)[1])>::value, "fun"); // #2 template<> void g<1,int>(fPtr<1,int>const(&)[1]){} GCC gives very misleading error message: error: specialization of 'void g(decltype (af<N, T>)&) [with unsigned int N = 1; T = int; decltype (af<N, T>) = void (* [1])(const int*)]' after instantiation 21 | void g<1,int>(fPtr<1,int>const(&)[1]){} | ^