https://github.com/MaskRay created 
https://github.com/llvm/llvm-project/pull/225584

#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

>From 637c57cc0a8e77e30ec22d9c31b34ff5f058e3aa Mon Sep 17 00:00:00 2001
From: Fangrui Song <[email protected]>
Date: Tue, 22 Sep 2026 20:34:24 -0700
Subject: [PATCH] [clang] Widen SubstTemplateTypeParmType::PackIndex to 16 bits

 #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
---
 clang/include/clang/AST/TypeBase.h      | 2 +-
 clang/test/SemaCXX/make_integer_seq.cpp | 5 +++++
 2 files changed, 6 insertions(+), 1 deletion(-)

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@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;

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to