https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122310
--- Comment #2 from Nathaniel Shead <nshead at gcc dot gnu.org> --- Tracking down further... The issue is that we crash during read-in of the lambda's type_decl. It has a merge kind of MK_keyed, so we read its keyed decl (the declaration that the lambda is bound to) so that we can look it up from the attached decls. The issue is that the keyed decl in this case is 'do_nothing', and reading it in it uses the lambda's type. So when we compare 'do_nothing' we haven't finished reading its type in yet, and hence the crash. This is another recursive type situation (related: PR116317, PR118630). I think the solution in this case is ensuring that 'do_nothing' (i.e. the lambda's key decl) is streamed before the lambda's type_decl. This way, we first read 'do_nothing', find its existing dup, and then read its type. While reading its type we now process the lambda type_decl, get a backref to its key decl (the existing do_nothing), and correctly dedup to the existing lambda. And then do_nothing will correctly have a matching type with the existing one when we check is_matching_decl later.
