[clang] [clang][sema] Fix crash on class template instantiation when a member variable partial specialization has an invalid primary template (PR #202006)

Harlen Batagelo via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 16 18:57:28 PDT 2026


================
@@ -2535,7 +2535,8 @@ Decl *TemplateDeclInstantiator::VisitVarTemplatePartialSpecializationDecl(
 
   // Lookup the already-instantiated declaration and return that.
   DeclContext::lookup_result Found = Owner->lookup(VarTemplate->getDeclName());
-  assert(!Found.empty() && "Instantiation found nothing?");
+  if (Found.empty())
----------------
hbatagelo wrote:

Maybe the invariant is for well-formed code only?

We can keep the assertion by bailing out a bit early if the primary template is invalid. I'll push an updated version.

https://github.com/llvm/llvm-project/pull/202006


More information about the cfe-commits mailing list