https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107146
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- This seems like it was fixed already in GCC 12.2.0. testcase.ii: In instantiation of 'void fields_count() [with T = my_class]': testcase.ii:18:3: required from 'void binary_visit(T, U) [with <template-parameter-1-1> = less_impl; T = my_class*; U = my_class]' testcase.ii:21:26: required from 'void lt_fields(T, U) [with T = my_class*; U = my_class]' testcase.ii:30:43: required from here testcase.ii:6:37: error: no matching function for call to 'detect_fields_count_dispatch<type>(<brace-enclosed initializer list>, int, int)' testcase.ii:3:6: note: candidate: 'template<class T, long int N> decltype (T{}) detect_fields_count_dispatch(size_t_<N>, long int, int)' testcase.ii:3:6: note: template argument deduction/substitution failed: testcase.ii:6:37: note: couldn't deduce template parameter 'N' Most likely fixed by the patch for PR 105589 .