https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118349
--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Eric Gallager from comment #4) > Yes, it's just a hypothetical example, I probably wouldn't actually use such > a low value myself, but rather would determine an appropriate value > experimentally on a project-by-project basis. I argue there is no appropriate value. > It's mostly just a style thing; I find that the deeper template nesting gets > in a project, the harder to understand I find it to be. Surely that's true of any nesting, including deeply nested functions. Why is it particular to templates? > Also excessive > template depth can lead to code size bloat; I've seen this in some projects > that abuse certain boost templates, for example. Template bloat has nothing to do with instantiation *depth*, it's a design problem. Non-dependent code can (and sometimes should) be hoisted out into bases or functions that can be shared by different specializations. But you know what such hoisting does? It *increases* instantiation depth. Reducing the use of templates doesn't necessarily reduce code size. Sensible use of template can reduces code size (by avoiding code duplication) and the instantiation depth is an incidental implementation detail, not a sign of good or bad use of templates. > (In reply to Sam James from comment #3) > > People already misunderstand the current option as well (PR65042). It'd just > > get worse. > > This actually seems like a perfect example of a case where the user should > have been using -Wtemplate-depth= (if it had existed) instead of > -ftemplate-depth=. There was no justification given for using -ftemplate-depth in that PR so it's also not justification for -Wtemplate-depth.