[clang] [Clang] [Sema] Fix crash instantiating a member variable template partial specialization when the enclosing class template is deserialized (PR #202958)
Matheus Izvekov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 1 09:47:47 PDT 2026
================
@@ -2697,6 +2697,14 @@ void ASTDeclReader::VisitVarTemplatePartialSpecializationDecl(
RedeclarableResult Redecl = VisitVarTemplateSpecializationDeclImpl(D);
+ // A partial specialization whose primary template is invalid cannot be
+ // instantiated. Mark it invalid too so InstantiateClass skips it, the same
+ // way it already skips the invalid primary, instead of later looking for an
+ // instantiated primary that was never created.
+ if (VarTemplateDecl *Primary = D->getSpecializedTemplate();
+ Primary && Primary->isInvalidDecl())
+ D->setInvalidDecl();
----------------
mizvekov wrote:
Can we address the root cause instead? Why does this not crash without serialization, but does with it?
https://github.com/llvm/llvm-project/pull/202958
More information about the cfe-commits
mailing list