[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:05:55 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:

Regarding the new change, even if the lists are the same size, you still can't assume there are no packs or expansions, so this is still not correct.

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


More information about the cfe-commits mailing list