================
@@ -5873,8 +5873,14 @@ ASTContext::getSubstBuiltinTemplatePack(const 
TemplateArgument &ArgPack) {
 
   QualType Canon;
   TemplateArgument CanonArgPack = getCanonicalTemplateArgument(ArgPack);
-  if (!CanonArgPack.structurallyEquals(ArgPack))
+  if (!CanonArgPack.structurallyEquals(ArgPack)) {
     Canon = getSubstBuiltinTemplatePack(CanonArgPack);
+    // Refresh InsertPos, in case the recursive call above caused rehashing,
+    // which would invalidate the bucket pointer.
+    if (auto *T =
+            SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos))
+      return QualType(T, 0);
----------------
mizvekov wrote:

It should be impossible to find the node here.
You can use the same pattern we use in the other constructors in this file, 
something like:
```C++
      [[maybe_unused]] const auto *Nothing =
          SubstBuiltinTemplatePackTypes.FindNodeOrInsertPos(ID, InsertPos));
      assert(!Nothing);
```

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

Reply via email to