[PATCH] D112659: Add a limit to __make_integer_seq builtin.
Erich Keane via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 28 12:21:08 PDT 2021
erichkeane added a comment.
In D112659#3091501 <https://reviews.llvm.org/D112659#3091501>, @rsmith wrote:
> I wonder if more generally we should have a limit on either the size of a pack or the number of template arguments in a template specialization, rather than limiting only `__make_integer_seq`? I think a hand-rolled `make_integer_sequence` implementation should also be limited in the same way. Eg: https://godbolt.org/z/Yhb6E4vTG
That seems like a reasonable error, I agree. I looked into the number of template arguments in a specialization, however, i've been looking through all the places that `TemplateArgumentListInfo::addArgument` is called, and it seems that we do this kind of all over the place... I would imagine we would want to catch this as we are adding, since if we wait until after (when it is converted to a `ASTTemplateArgumentListInfo` or something), the damage has already been done, right?
Or am I taking this too literally?
> I'd also be inclined to pick a smaller default limit for the more general constraint. Maybe 64K? I think we should be aiming to pick a limit that causes template argument list explosions to be caught before the compiler runs out of memory and dies and before the user gets bored and interrupts the compilation, and 16M seems a bit high for both. For the above example, we take 6s on godbolt for 64K, and ~30s for 512K.
I don't mind a 64k default, I was concerned with what I did (16 million) being too small of a limit, but I don't have a good idea of the scale of what library folks end up doing for this.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112659/new/
https://reviews.llvm.org/D112659
More information about the cfe-commits
mailing list