https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94619
Bug ID: 94619 Summary: String literals as non-type template parameter fails to compile with partial specialization of calling function Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: pacoarjonilla at yahoo dot es Target Milestone: --- I'm not sure if this is correct C++, but the compiler seems to be unable to deduce the template parameter of fu when it is a non-type kind. If the code is not correct, this error blocks fu from being overloaded by more specific templates :( The diagnostic " mismatched types ‘A<length>’ and ‘A<...auto...>’ " is suspicious of a bug in GCC >>>>>>>>>>>>>>>>>>>>>>>>>>> template <unsigned length> struct A { char str [length]; constexpr A(char const (&s) [length]) { for (int i = 0; i < length; ++i) str[i] = s[i]; } }; template <A a> struct B { void bar() const { return a.str; } }; //template <typename T> void fu (T const& t) // Compiles successfully template <A a> void fu (B<a> const& t) // Does not compile //template <unsigned l> void fu (B<A<l>> const& t) // Does not compile either { t.bar(); } void test() { B<":/"> m; fu(m); } >>>>>>>>>>>>>>>>>>>>>>>>>>> gcc10 --std=c++20 code.cc -c meta.cc:17:37: error: class template argument deduction failed: 17 | template <A a> void fu (B<a> const& t) // Does not compile | ^ meta.cc:17:37: error: no matching function for call to ‘A(A<...auto...>)’ meta.cc:4:15: note: candidate: ‘template<unsigned int length> A(const char (&)[length])-> A<length>’ 4 | constexpr A(char const (&s) [length]) { | ^ meta.cc:4:15: note: template argument deduction/substitution failed: meta.cc:17:37: note: mismatched types ‘const char [length]’ and ‘A<...auto...>’ 17 | template <A a> void fu (B<a> const& t) // Does not compile | ^ meta.cc:1:35: note: candidate: ‘template<unsigned int length> A(A<length>)-> A<length>’ 1 | template <unsigned length> struct A { | ^ meta.cc:1:35: note: template argument deduction/substitution failed: meta.cc:17:37: note: mismatched types ‘A<length>’ and ‘A<...auto...>’ 17 | template <A a> void fu (B<a> const& t) // Does not compile | ^ meta.cc: In function ‘void fu(const int&)’: meta.cc:20:9: error: request for member ‘bar’ in ‘t’, which is of non-class type ‘const int’ 20 | t.bar(); | ^~~ meta.cc: In function ‘void test()’: meta.cc:25:9: error: no matching function for call to ‘fu(B<A<3>{":/"}>&)’ 25 | fu(m); | ^ meta.cc:17:30: note: candidate: ‘template<A<...auto...> a> void fu(const int&)’ 17 | template <A a> void fu (B<a> const& t) // Does not compile | ^~ meta.cc:17:30: note: template argument deduction/substitution failed: meta.cc:25:9: note: couldn’t deduce template parameter ‘a’ 25 | fu(m); | ^