[clang] [clang][Sema] fix crash on __type_pack_element with dependent packs (GH180307) (PR #180407)
via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 9 03:01:15 PST 2026
================
@@ -3406,6 +3406,10 @@ static QualType checkBuiltinTemplateIdType(
Sema &SemaRef, ElaboratedTypeKeyword Keyword, BuiltinTemplateDecl *BTD,
ArrayRef<TemplateArgument> Converted, SourceLocation TemplateLoc,
TemplateArgumentListInfo &TemplateArgs) {
+ if (llvm::any_of(Converted,
+ [](const TemplateArgument &A) { return A.isDependent(); }))
+ return QualType();
----------------
Serosh-commits wrote:
> Oh huh, I wouldn't have thought of doing it this way. Good call.
>
> Are we able to check that the minimum arg count is reached? e.g
>
> ```c++
> __some_builtin_template<{some template parameter set}>(...)
> ```
>
> is always invalid if there are insufficient template parameters (assuming no packs), e.g we can error out on incorrect/insufficient template parameters even if they are dependent
Thanks That's a great point. If the arity is already insufficient, the template is invalid regardless of dependency. I can update the top-level gatekeeper to also check Converted.size() against getMinRequiredArguments()
this would catch these cases early and ensure that the case-specific internal assertions are always safe. Does that sound good to you?
https://github.com/llvm/llvm-project/pull/180407
More information about the cfe-commits
mailing list