llvm / llvm/llvm-project

clang 22.1.2 crashes (SIGSEGV) instantiating template method with TVariant in C++26 mode (-std=c++26)

Open
#190,486 4 comments 0 reactions 0 assignees View on GitHub
clang waiting-for-response
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

**Component:** C++ Frontend / Template Instantiation

**Reproducible with:** clang 22.1.2, `-std=c++26`, Linux x86_64

**Summary:**
clang 22.1.2 crashes with exit code 139 (SIGSEGV) when instantiating a template method that emplaces into a `TVariant` (Unreal Engine's variant type) under `-std=c++26`. The same code compiles cleanly under `-std=c++23`. The crash occurs in `TreeTransform::TransformTemplateTypeParmType` during instantiation of `FBuildActionBuilderInternal::Add`.

**Crash backtrace key frames:**
```
TemplateInstantiator::TransformTemplateTypeParmType
TreeTransform::TransformType(TypeSourceInfo*)
TreeTransform::TransformType(QualType)
TemplateInstantiator::TransformTemplateArgument
```

**Minimal reproducer** (simplified from UE5 `DerivedDataBuildAction.cpp:65`):
```cpp
#include
#include

template
struct TVariant : std::variant {
using std::variant::variant;
};

template
struct TInPlaceType {};

struct FCbObject {};
struct FIoHash {};

class FBuildActionBuilderInternal {
using InputType = TVariant>;

template
void Add(std::string_view Key, const ValueType& Value) {
InputType input(TInPlaceType{}, Value);
(void)input;
}

void Test() {
FCbObject obj;
Add("key", obj);
}
};
```

**To reproduce:**
```bash
clang++ -std=c++26 -c reproducer.cpp
```

**Expected:** Compiles cleanly (works with `-std=c++23`)
**Actual:** SIGSEGV, exit 139

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.