[all-commits] [llvm/llvm-project] e8e88d: [clang][sema] Fix crash on class template instanti...
Harlen Batagelo via All-commits
all-commits at lists.llvm.org
Tue Jul 14 00:12:52 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e8e88dbde96a75ffe0e8bf10ea9481a053292421
https://github.com/llvm/llvm-project/commit/e8e88dbde96a75ffe0e8bf10ea9481a053292421
Author: Harlen Batagelo <hbatagelo at gmail.com>
Date: 2026-07-14 (Tue, 14 Jul 2026)
Changed paths:
M clang/docs/ReleaseNotes.md
M clang/lib/Sema/SemaTemplateInstantiate.cpp
A clang/test/SemaTemplate/GH195988.cpp
Log Message:
-----------
[clang][sema] Fix crash on class template instantiation when a member variable partial specialization has an invalid primary template (#202006)
Fixes #195988.
For the root cause, consider this reproducer:
https://godbolt.org/z/6jTnvocs4
```cpp
template <typename> struct A {
template <typename U> static B x; // unknown type name 'B'
template <typename U> static int x<U*>;
};
A<int> a;
```
During the instantiation of `A<int>`, the variable template `x` is
skipped because it was marked as an invalid declaration due to the
unknown type `B`. When the partial specialization `x<U*>` is visited
next, the lookup for `x` finds nothing and triggers the assertion:
https://github.com/llvm/llvm-project/blob/2433b06e6dbe3ef015a226620d207a45f7b98c7c/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp#L2538
Fix by instantiating invalid variable templates using the `int` fallback
instead of skipping them.
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