https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92101
Bug ID: 92101 Summary: Class template partial specializations with class NTTP does not work Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: mateusz.pusz at gmail dot com Target Milestone: --- Assuming the following basic_fixed_string implementation ``` #include <cstdlib> template<typename CharT, std::size_t N> struct basic_fixed_string { CharT data_[N+1] = {}; constexpr basic_fixed_string(const CharT (&txt)[N+1]) noexcept { for(std::size_t i = 0; i <= N; ++i) data_[i] = txt[i]; } // auto operator==(const basic_fixed_string &) = default; }; template<typename CharT, std::size_t N> basic_fixed_string(const CharT (&str)[N]) -> basic_fixed_string<CharT, N-1>; ``` the following works: ``` template<basic_fixed_string Name, typename...> struct A { static constexpr auto name = Name; }; struct B : A<"abc", int> {}; ``` but the following does not work ``` template<basic_fixed_string Name, typename...> struct A; template<basic_fixed_string Name, typename T1> struct A<Name, T1> { static constexpr auto name = Name; }; struct B : A<"abc", int> {}; ``` Fails with the following error: ``` source>:26:18: error: class template argument deduction failed: 26 | struct A<Name, T1> { | ^ <source>:26:18: error: no matching function for call to 'basic_fixed_string(basic_fixed_string<...auto...>)' <source>:16:1: note: candidate: 'template<class CharT, long unsigned int N> basic_fixed_string(const CharT (&)[N])-> basic_fixed_string<CharT, (N - 1)>' 16 | basic_fixed_string(const CharT (&str)[N]) -> basic_fixed_string<CharT, N-1>; | ^~~~~~~~~~~~~~~~~~ <source>:16:1: note: template argument deduction/substitution failed: <source>:26:18: note: mismatched types 'const CharT [N]' and 'basic_fixed_string<...auto...>' 26 | struct A<Name, T1> { | ^ <source>:7:15: note: candidate: 'template<class CharT, long unsigned int N> basic_fixed_string(const CharT (&)[(N + 1)])-> basic_fixed_string<CharT, N>' 7 | constexpr basic_fixed_string(const CharT (&txt)[N+1]) noexcept | ^~~~~~~~~~~~~~~~~~ <source>:7:15: note: template argument deduction/substitution failed: <source>:26:18: note: mismatched types 'const CharT [(N + 1)]' and 'basic_fixed_string<...auto...>' 26 | struct A<Name, T1> { | ^ <source>:4:8: note: candidate: 'template<class CharT, long unsigned int N> basic_fixed_string(basic_fixed_string<CharT, N>)-> basic_fixed_string<CharT, N>' 4 | struct basic_fixed_string { | ^~~~~~~~~~~~~~~~~~ <source>:4:8: note: template argument deduction/substitution failed: <source>:26:18: note: mismatched types 'basic_fixed_string<CharT, N>' and 'basic_fixed_string<...auto...>' 26 | struct A<Name, T1> { | ^ <source>:30:12: error: invalid use of incomplete type 'struct A<basic_fixed_string<char, 3>{"abc"}, int>' 30 | struct B : A<"abc", int> {}; | ^~~~~~~~~~~~~ <source>:23:8: note: declaration of 'struct A<basic_fixed_string<char, 3>{"abc"}, int>' 23 | struct A; | ^ Compiler returned: 1 ``` Godbolt link: https://godbolt.org/z/MCdhTJ