[clang] [clang] Widen SubstTemplateTypeParmType::PackIndex to 16 bits (PR #225584)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 22 21:12:42 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Fangrui Song (MaskRay)
<details>
<summary>Changes</summary>
#<!-- -->132748 narrowed PackIndex to 15 bits when adding Final, leaving a bit
unused, so a type pack with 32768 or more elements stores a wrapped pack
index. The node then keys differently from its lookup, failing the
UniquingSet insert assertion. Restore the 16-bit width, matching
SubstPackType's 16-bit NumArgs.
Fix assertion failure godbolt.org/z/9r1jEqqob
Aided by Opus 5.5
---
Full diff: https://github.com/llvm/llvm-project/pull/225584.diff
2 Files Affected:
- (modified) clang/include/clang/AST/TypeBase.h (+1-1)
- (modified) clang/test/SemaCXX/make_integer_seq.cpp (+5)
``````````diff
diff --git a/clang/include/clang/AST/TypeBase.h b/clang/include/clang/AST/TypeBase.h
index 28f102fdaf534c..5acda5ad6e4a8d 100644
--- a/clang/include/clang/AST/TypeBase.h
+++ b/clang/include/clang/AST/TypeBase.h
@@ -2270,7 +2270,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
/// increments towards the beginning.
/// Positive non-zero number represents the index + 1.
/// Zero means this is not substituted from an expansion.
- unsigned PackIndex : 15;
+ unsigned PackIndex : 16;
};
class SubstPackTypeBitfields {
diff --git a/clang/test/SemaCXX/make_integer_seq.cpp b/clang/test/SemaCXX/make_integer_seq.cpp
index 71b7b8260d4abc..58e218403a8b51 100644
--- a/clang/test/SemaCXX/make_integer_seq.cpp
+++ b/clang/test/SemaCXX/make_integer_seq.cpp
@@ -50,3 +50,8 @@ __make_integer_seq<f, int, 0> x; // expected-error{{template template parameter
__make_integer_seq<__make_integer_seq, int, 10> PR28494; // expected-note{{different template parameters}}
// expected-error at make_integer_seq.cpp:* {{template argument for template template parameter must be a class template or type alias template}}
+
+// The largest type pack whose pack indices fit in SubstTemplateTypeParmType.
+template <class... Ts> using Expand = void(Ts...);
+template <class T, T... I> struct ExpandSeq { using type = Expand<decltype(I)...>; };
+using LargePack = __make_integer_seq<ExpandSeq, int, 65535>::type;
``````````
</details>
https://github.com/llvm/llvm-project/pull/225584
More information about the cfe-commits
mailing list