[clang] [clang][Sema] fix crash on __type_pack_element with dependent packs (GH180307) (PR #180407)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 22 12:02:32 PST 2026
================
@@ -3406,25 +3406,39 @@ static QualType checkBuiltinTemplateIdType(
Sema &SemaRef, ElaboratedTypeKeyword Keyword, BuiltinTemplateDecl *BTD,
ArrayRef<TemplateArgument> Converted, SourceLocation TemplateLoc,
TemplateArgumentListInfo &TemplateArgs) {
+ TemplateParameterList *Params = BTD->getTemplateParameters();
+ unsigned RequiredArgs = Params->size();
+ if (Params->hasParameterPack()) {
+ if (Converted.size() < RequiredArgs)
+ return QualType();
+ } else {
+ if (Converted.size() != RequiredArgs)
+ return QualType();
+ }
----------------
mizvekov wrote:
Sorry for not responding earlier.
A template argument list can contain a pack argument, which is another list with a fixed size.
So a list with with this structure: "(1, (1, 2, 3))" has size four, instead of two. I don't think at the moment a template argument pack can itself contain another pack.
Also, a template argument can be a pack expansion. A pack expansion can have known size, in which case you just account for that size, or it can have unknown size, which is at minimum 0, with no maximum, so for these lists you can only know the minimum size.
https://github.com/llvm/llvm-project/pull/180407
More information about the cfe-commits
mailing list