https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95015
Bug ID: 95015 Summary: Partial specializations of class templates with class NTTP fails Product: gcc Version: 11.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: --- The following code does not compile: ``` template<typename T> struct X { T a; int b; }; template<typename T> X(T, int) -> X<T>; // <- does not work // X(T) -> X<T>; // < works template<X V> struct Y {}; template<typename T> inline constexpr bool is_Y = false; template<X NTTP> inline constexpr bool is_Y<Y<NTTP>> = true; X x(3, 3); Y<X(3, 3)> y; using my_y = Y<X(3, 3)>; static_assert(is_Y<my_y>); ``` The error is: ``` <source>:16:30: error: class template argument deduction failed: 16 | inline constexpr bool is_Y<Y<NTTP>> = true; | ^~~~ <source>:16:30: error: no matching function for call to 'X(X<...auto...>)' <source>:2:8: note: candidate: 'template<class T> X()-> X<T>' 2 | struct X { | ^ <source>:2:8: note: template argument deduction/substitution failed: <source>:16:30: note: candidate expects 0 arguments, 1 provided 16 | inline constexpr bool is_Y<Y<NTTP>> = true; | ^~~~ <source>:2:8: note: candidate: 'template<class T> X(X<T>)-> X<T>' 2 | struct X { | ^ <source>:2:8: note: template argument deduction/substitution failed: <source>:16:30: note: mismatched types 'X<T>' and 'X<...auto...>' 16 | inline constexpr bool is_Y<Y<NTTP>> = true; | ^~~~ <source>:7:1: note: candidate: 'template<class T> X(T, int)-> X<T>' 7 | X(T, int) -> X<T>; // <- does not work | ^ <source>:7:1: note: template argument deduction/substitution failed: <source>:16:30: note: candidate expects 2 arguments, 1 provided 16 | inline constexpr bool is_Y<Y<NTTP>> = true; | ^~~~ <source>:16:23: error: template argument 1 is invalid 16 | inline constexpr bool is_Y<Y<NTTP>> = true; | ^~~~~~~~~~~~~ <source>:16:23: error: template-id 'is_Y<<expression error> >' for 'is_Y' does not match any template declaration <source>:14:23: note: candidate is: 'template<class T> constexpr const bool is_Y<T>' 14 | inline constexpr bool is_Y = false; | ^~~~ <source>:21:15: error: static assertion failed 21 | static_assert(is_Y<my_y>); | ^~~~~~~~~~ Compiler returned: 1 ``` https://godbolt.org/z/597fXY