https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103096
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> --- We'd need next to the instantiation depth limit something that would be incremented for every nested instantiation and when this counter reaches some limit, also fail like reaching the instantiation depth limit does. E.g. with -ftemplate-depth=27 it takes on #c3 about 19s on my box to fail, so a default limit for such counter of something like 2^23 to 2^27 might be ok (we'd need to see what is actually reached on boost). -ftemplate-depth=30 seems to be already too slow.