llvm-project
llvm-project copied to clipboard
Frontend segfault when a function-local static variable is used as a reference non-type template argument
Environment
Clang 19.1.0 (x86-64-unknown-linux-gnu, release build without assertions)
Command
$ clang++ -c test7.cpp
Actual behavior
Segmentation fault (the front end queries constant-size-type info on a dependent type).
Additional notes
The template is instantiated with a reference to a static variable local to a function template. The test case was produced by an automated compiler-testing tool (GapSmith).
Test case (test7.cpp)
#include <iostream>
template<int& T>
void FuncTemplate() {
std::cout << "Template instantiated with reference to int: " << T << std::endl;
}
template<int i> class A {};
template<int i> void g(A<i> &) {
static int InternalVar = 43;
FuncTemplate<InternalVar>();
}
int main()
{
A<1> a;
g(a);
}
@llvm/issue-subscribers-clang-frontend
Author: ICSE-27
## Environment
Clang 19.1.0 (x86-64-unknown-linux-gnu, release build without assertions)
Command
clang++ -c test7.cpp
Actual behavior
Segmentation fault (the front end queries constant-size-type info on a dependent type).
Additional notes
The template is instantiated with a reference to a static variable local to a function template. The test case was produced by an automated compiler-testing tool (GapSmith).
Test case (test7.cpp)
#include <iostream>
template<int& T>
void FuncTemplate() {
std::cout << "Template instantiated with reference to int: " << T << std::endl;
}
template<int i> class A {};
template<int i> void g(A<i> &) {
static int InternalVar = 43;
FuncTemplate<InternalVar>();
}
int main()
{
A<1> a;
g(a);
}