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

            Bug ID: 102044
           Summary: another case of template function signature
                    incorrectly dropping top-level cv-qualifier with
                    function parameter of array of template function
                    pointer
           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: ---

This may be dup case of PR102033, PR102034 and very probably not related with
PR102042 of which I just changed the function parameter of "g" to const array
instead of const reference of array. So, it can be another test case.

However, clang(https://www.godbolt.org/z/fxzoWK4G8) passes,
MSVC++(https://www.godbolt.org/z/c7Pfbr6b9) fails like GCC. In this sense, I
believe this case might be different from all above cases because MSVC++ does
not fail.

consider:

#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>)){}

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(const fPtr<1,int>[1])>::value, "fun"); // #2

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


GCC says:

 error: template-id 'g<1, int>' for 'void g(void (* const*)(const int*))' does
not match any template declaration
   21 | void g<1,int>(const fPtr<1,int>[1]){}
      |      ^~~~~~~~
fun-array-value.cpp:12:6: note: candidate is: 'template<unsigned int N, class
T> void g(decltype (af<N, T>))'
   12 | void g(const decltype(af<N,T>)){}
      |      ^

Reply via email to