https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94521
--- Comment #2 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Patrick Palka <ppa...@gcc.gnu.org>: https://gcc.gnu.org/g:1dcb779916502a44b4ae67d6bf60eb59474bd78c commit r10-7705-g1dcb779916502a44b4ae67d6bf60eb59474bd78c Author: Patrick Palka <ppa...@redhat.com> Date: Mon Apr 13 16:53:41 2020 -0400 c++: Infinite diagnostic loop with decltype([]{}) [PR94521] We are hitting a recursive loop when printing the signature of a function containing a decltype([]{}) type. The loop is dump_function_decl -> dump_substitution -> dump_template_bindings -> dump_type -> dump_aggr_type -> dump_scope -> dump_function_decl and we loop because dump_template_bindings wants to print the resolved type of decltype([]{}) (i.e. just a lambda type), so it calls dump_aggr_type, which wants to print the function scope of the lambda type. But the function scope of the lambda type is the function which we're in the middle of printing. This patch breaks the loop by passing TFF_NO_FUNCTION_ARGUMENTS to dump_function_decl from dump_scope, so that we avoid recursing into dump_substitution and ultimately looping. This also means we no longer emit the "[with ...]" clause when printing a function template scope, and we instead just emit its template argument list in a more natural way, e.g. instead of foo(int, char) [with T=bool]::x we would now print foo<bool>::x which seems like an improvement on its own. The full signature of the function 'spam' in the below testcase is now void spam(decltype (<lambda>)*) [with T = int; decltype (<lambda>) = spam<int>::<lambda()>] gcc/cp/ChangeLog: PR c++/94521 * error.c (dump_scope): Pass TFF_NO_FUNCTION_ARGUMENTS to dump_function_decl when printing a function template instantiation as a scope. gcc/testsuite/ChangeLog: PR c++/94521 * g++.dg/cpp2a/lambda-uneval12.C: New test.