[Bug c++/102042] specialization after instantiation error possibly rooted from mis-calculating template function signature of parameter of array of template function

nickhuang99 at hotmail dot com gcc-bugzilla@gcc.gnu.org
Tue Aug 24 14:41:03 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102042

--- Comment #1 from qingzhe huang <nickhuang99 at hotmail dot com> ---
Slightly change the prototype of "g" from reference to pointer, you have exact
same error. (please note #0 changes to pointer type)


#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>};

template<unsigned int N, class T>
void g(const decltype(af<N,T>)*){} // #0

static_assert(std::is_same<decltype(g<1,int>),
 void(const fPtr<1,int>(*)[1])>::value, "fun"); // #2

template<>
void g<1,int>(const fPtr<1,int>(*)[1]){}



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
   24 | void g<1,int>(const fPtr<1,int>(*)[1]){}
      |


More information about the Gcc-bugs mailing list