https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47202
--- Comment #3 from Jason Merrill <jason at gcc dot gnu.org> --- This is an issue of combinatorial explosion in checking code; when we have lots of substitutions, checking each one against each other takes a long time, especially when each comparison involves recursively comparing all the template arguments. In release mode we don't do the substitution checking and type comparison just uses canonical types. We ought to hit the recursion limit before we try to do the mangling, though; this is an issue with DECL_COMDAT_GROUP that I've been meaning to address. I think I'll dig out that branch again...