Crash in CodeGenModule::HandleCXXStaticMemberVarInstantiation for a static data member with a dependent nested-alias type missing typename
Description
Clang crashes (release build without assertions) when instantiating the
out-of-line definition of a static data member of a class template, when the
member's type is a dependent nested alias written without typename:
template <class T>
struct Tester {
struct Inner { using T2 = int; };
static void test();
};
template <class T>
struct W { static Tester<T>::Inner::T2 m; };
template <class T>
Tester<T>::Inner::T2 W<T>::m = 0;
template struct W<int>;
clang++ -std=c++17 -c repro.cpp
Expected / Observed
Expected: a diagnostic error (missing typename — this is what GCC produces).
Observed: crash with stack dump at CodeGenModule::HandleCXXStaticMemberVarInstantiation
(clang/lib/CodeGen/CodeGenModule.cpp:5956), reached via
~PassToConsumerRAII / Sema::InstantiateVariableDefinition. Reproduces at
every optimization level and language mode; also on Clang 19.1.7.
At minimum Clang should diagnose the program instead of crashing; the crash
site is distinct from the return-type-driven getTypeInfoImpl failure shape
of similar missing-typename reproducers.
@llvm/issue-subscribers-clang-codegen
Author: ICSE-27
Clang crashes (release build without assertions) when instantiating the
out-of-line definition of a static data member of a class template, when the
member's type is a dependent nested alias written without typename:
template <class T>
struct Tester {
struct Inner { using T2 = int; };
static void test();
};
template <class T>
struct W { static Tester<T>::Inner::T2 m; };
template <class T>
Tester<T>::Inner::T2 W<T>::m = 0;
template struct W<int>;
clang++ -std=c++17 -c repro.cpp
Expected / Observed
Expected: a diagnostic error (missing typename — this is what GCC produces).
Observed: crash with stack dump at CodeGenModule::HandleCXXStaticMemberVarInstantiation
(clang/lib/CodeGen/CodeGenModule.cpp:5956), reached via
~PassToConsumerRAII / Sema::InstantiateVariableDefinition. Reproduces at
every optimization level and language mode; also on Clang 19.1.7.
At minimum Clang should diagnose the program instead of crashing; the crash
site is distinct from the return-type-driven getTypeInfoImpl failure shape
of similar missing-typename reproducers.