llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Crash in CodeGenTypes::ConvertTypeForMem for a static array member with a dependent nested-alias element type missing typename

Open ICSE-27 opened this issue 2 months ago • 1 comments

Description

Variant of the same ill-typed static member pattern with an array member — taking the address of the static array crashes in a different CodeGen function:

template <class T>
struct Tester {
   struct Inner { using T2 = int; };
};
template <class T>
struct W { static Tester<T>::Inner::T2 m[2]; };
template <class T>
Tester<T>::Inner::T2 W<T>::m[2] = {1, 2};
template struct W<int>;
clang++ -std=c++17 -c repro.cpp

Expected / Observed

Expected: a diagnostic error (missing typename, as GCC produces). Observed: crash with stack dump at clang::CodeGen::CodeGenTypes::ConvertTypeForMem (CodeGenTypes.cpp:107), reached from GetAddrOfGlobalVar ← HandleCXXStaticMemberVarInstantiation. Every optimization level; also Clang 19.1.7.

ICSE-27 avatar Sep 28 '26 04:09 ICSE-27

@llvm/issue-subscribers-clang-codegen

Author: ICSE-27

## Description

Variant of the same ill-typed static member pattern with an array member — taking the address of the static array crashes in a different CodeGen function:

template &lt;class T&gt;
struct Tester {
   struct Inner { using T2 = int; };
};
template &lt;class T&gt;
struct W { static Tester&lt;T&gt;::Inner::T2 m[2]; };
template &lt;class T&gt;
Tester&lt;T&gt;::Inner::T2 W&lt;T&gt;::m[2] = {1, 2};
template struct W&lt;int&gt;;
clang++ -std=c++17 -c repro.cpp

Expected / Observed

Expected: a diagnostic error (missing typename, as GCC produces). Observed: crash with stack dump at clang::CodeGen::CodeGenTypes::ConvertTypeForMem (CodeGenTypes.cpp:107), reached from GetAddrOfGlobalVar ← HandleCXXStaticMemberVarInstantiation. Every optimization level; also Clang 19.1.7.