https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100893
Bug ID: 100893 Summary: Template argument conversion fails for dependant constant function pointer template parameters Product: gcc Version: 11.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jlegg at feralinteractive dot com Target Milestone: --- When compiling this C++ code: void f(); struct S {using F = void (* const)();}; template <typename T, typename T::F f> void g() {} void h() {g<S, &f>();} GCC 11.1.1, and (much) earlier versions, reject it with: <source>: In function 'void h()': <source>:4:19: error: no matching function for call to 'g<S, f>()' 4 | void h() {g<S, &f>();} | ~~~~~~~~^~ <source>:3:45: note: candidate: 'template<class T, typename T::F f> void g()' 3 | template <typename T, typename T::F f> void g() {} | ^ <source>:3:45: note: template argument deduction/substitution failed: <source>:4:16: error: could not convert template argument 'f' from 'void (*)()' to 'void (* const)()' 4 | void h() {g<S, &f>();} | ^~ My language lawyering isn't good enough to explain why, but I think the template argument conversion should work, and the compiler should behave as it does when the const is removed. Similar conversions seem to work if F is a constant type but not a function pointer, or if the second template parameter on g is not dependant on the first. MSVC and Clang also accept the example code.