https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97751
Bug ID: 97751 Summary: C++20 NTTP: class template argument deduction failed Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: janpmoeller at gmx dot de Target Milestone: --- The following code results in a hard compile error in gcc-10.2 and the latest trunk: ///////////////////////////////////////////////////////////////////////////// template <int N> struct use_as_nttp {}; template <use_as_nttp Value> struct has_nttp {}; template <use_as_nttp Value> using has_nttp_2 = has_nttp<Value>; ///////////////////////////////////////////////////////////////////////////// This is the output: ############################################################################# <source>:8:34: error: class template argument deduction failed: 8 | using has_nttp_2 = has_nttp<Value>; | ^ <source>:8:34: error: no matching function for call to 'use_as_nttp(use_as_nttp<...auto...>)' <source>:2:8: note: candidate: 'template<int N> use_as_nttp()-> use_as_nttp<N>' 2 | struct use_as_nttp {}; | ^~~~~~~~~~~ <source>:2:8: note: template argument deduction/substitution failed: <source>:8:34: note: candidate expects 0 arguments, 1 provided 8 | using has_nttp_2 = has_nttp<Value>; | ^ <source>:2:8: note: candidate: 'template<int N> use_as_nttp(use_as_nttp<N>)-> use_as_nttp<N>' 2 | struct use_as_nttp {}; | ^~~~~~~~~~~ <source>:2:8: note: template argument deduction/substitution failed: <source>:8:34: note: mismatched types 'use_as_nttp<N>' and 'use_as_nttp<...auto...>' 8 | using has_nttp_2 = has_nttp<Value>; | ^ Compiler returned: 1 ############################################################################# gcc was invoked with "-std=c++20 -Wall -Wextra -Wpedantic". The error can also be observed on compiler explorer: https://godbolt.org/z/xbPrjj I believe that this is valid C++20 and should compile (but not generate any assembly, since none of the types are actually instantiated).