llvm / llvm/llvm-project

Clang crashes when constructor initializer list contains a template parameter type

Open
#201,593 3 comments 0 reactions 1 assignee Claimed by @spaits View on GitHub
clang:diagnostics clang:frontend crash-on-invalid
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

Clang crashes on the following ~~valid~~ invalid C++ code (when assertions are enabled):
```cpp
struct S0 {
S0(int) {}
template
S0(T) : Member(42), T(42) {};
int Member{21};
};

void InstantiateS0() {
S0 S0Instance(67);
}
```

```
Assertion `IdealIndex < NumIdealInits && "initializer not found in initializer list"' failed.
```

The reproducer on Compiler Explorer:
https://godbolt.org/z/xaEWMM5b5

The correct behaviour would be accepting the code, and warning for the wrong initialization order.

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.