[clang] [clang] Prevent stack overflow on deeply nested template arguments (PR #224393)

Younan Zhang via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 20 06:56:59 PDT 2026


zyn0217 wrote:

We already have stack guards protecting instantiation from stack overflows like this, which makes sense given that recursive instantiation chains are common in metaprogramming world.

However a stack guard also adds overhead to a function call, and with this we have to pay a little more when parsing a template argument and the add-up could be huge when running in a template heavy codebase where the template argument lists are often long rather than deep.

Indeed this could be seen as a Parser bug, but I think this is more like a trade-off that we don't want pay much for unusual code patterns that can be written by human.

https://github.com/llvm/llvm-project/pull/224393


More information about the cfe-commits mailing list