[all-commits] [llvm/llvm-project] 24e7de: [clang] Fix crash in VisitVarTemplatePartialSpecia...

Aayush Shrivastava via All-commits all-commits at lists.llvm.org
Wed Jul 1 18:27:48 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 24e7deef7363d5dce2255c5350645b927e5e3313
      https://github.com/llvm/llvm-project/commit/24e7deef7363d5dce2255c5350645b927e5e3313
  Author: Aayush Shrivastava <iamaayushrivastava at gmail.com>
  Date:   2026-07-01 (Wed, 01 Jul 2026)

  Changed paths:
    M clang/docs/ReleaseNotes.md
    M clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
    A clang/test/SemaTemplate/GH198890.cpp

  Log Message:
  -----------
  [clang] Fix crash in VisitVarTemplatePartialSpecializationDecl on failed instantiation (#200161)

Fixes #198890

When a class template is explicitly instantiated and a member variable
template's type involves a substitution failure (e.g. `typename T::type`
with `T=int`), `VisitVarDecl` returned `nullptr`, causing
`VisitVarTemplateDecl` to bail out before registering the
`VarTemplateDecl` in the owner's lookup table. A subsequent call to
`VisitVarTemplatePartialSpecializationDecl` then hit an assert
(`!Found.empty()`) on the empty lookup result.

Fix: When `SubstType` fails and `InstantiatingVarTemplate=true`, recover
by using `int` as the type (via `getTrivialTypeSourceInfo(IntTy)`) and
mark the resulting `VarDecl` invalid. This ensures
`VisitVarTemplateDecl` always receives a valid `VarDecl` and finishes
registering the `VarTemplateDecl`, preserving the invariant the asserts
rely on.

A regression test is added in `clang/test/SemaTemplate/GH198890.cpp`.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list