https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70909
--- Comment #20 from Mark Wielaard <mark at gcc dot gnu.org> --- Created attachment 40213 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=40213&action=edit Add is_cyclic check to d_lookup_template_argument The patch that Marcel originally proposed tried to catch any recursive printing and if so stop (but not fail) the demangling. The reviews seemed to suggest that people found this a bit too costly and that the check should be more specific and that it should produce an error. https://gcc.gnu.org/ml/gcc-patches/2016-05/msg02093.html https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01985.html So maybe we should extract the cyclic detection so it can be used in "debug mode" and inserted in the "right place". The attached does that (minus adding a debug mode) and catches some of the crashes.