[clang] [clang][Sema] fix crash on __type_pack_element with dependent packs (GH180307) (PR #180407)

Oliver Hunt via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 11 19:51:03 PST 2026


================
@@ -3406,10 +3406,16 @@ static QualType checkBuiltinTemplateIdType(
     Sema &SemaRef, ElaboratedTypeKeyword Keyword, BuiltinTemplateDecl *BTD,
     ArrayRef<TemplateArgument> Converted, SourceLocation TemplateLoc,
     TemplateArgumentListInfo &TemplateArgs) {
+  if (Converted.size() < BTD->getTemplateParameters()->size())
+    return QualType();
+
   ASTContext &Context = SemaRef.getASTContext();
 
   switch (BTD->getBuiltinTemplateKind()) {
   case BTK__make_integer_seq: {
+    assert(Converted.size() == 3);
----------------
ojhunt wrote:

I think this assertion will fire if you do `__make_integer_seq<a,b,c,d,e>` or similar. It's possible the above size check should be `Converted.size() == BTD->getTemplateParameters()->size()` unless the last parameter is variadic, in which case it should permit more parameters.

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


More information about the cfe-commits mailing list