<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/96077>96077</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
reproducible clangd crash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
nommse
</td>
</tr>
</table>
<pre>
Hello,
I stumbled over a `clangd` crash when analyzing our code base with `clang-tidy`. Trying to break this down resulted in the following code snippet:
`#include <functional>
struct S
{
std::function<void()> func;
};
struct F
{
std::function<S(int)> f = [this] (auto) { return S{.func = [this]() {}}; };
};
int main() {}
`
[clangd-18.1.6-crash.log](https://github.com/user-attachments/files/15902010/clangd-18.1.6-crash.log)
[clangd-19.0.0-crash.log](https://github.com/user-attachments/files/15902011/clangd-19.0.0-crash.log)
The crash can be reproduced with versions 18.1.3, 18.1.6 and 19.0.0 when invoking `clangd` like so:
`clangd --clang-tidy --check=test.cpp --log=verbose`
If the function `F::f` is defined in one of the following ways, `clangd` does not crash:
`
std::function<S(int)> f = [this] (int) { return S{.func = [this]() {}}; };
std::function<S(int)> f = [this] (auto) -> S { return S{.func = [this]() {}}; };
std::function<S(int)> f = [] (auto) { return S{.func = []() {}}; };
`
Thank you and best regards,
Normen Bolling
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VcGS4jYQ_Zrm0mWXLGFjH3wYhqWyl1xmfkC2GqyMkChJhiJfn5LNDDCTTVLJVjjYwup-et16T5Ih6L0laqFcQ7lZyDEOzrfWHQ6BFp1Tl_YXMsYBfwa2AfY0P79jiOOhM6TQncijRKhYb6TdK6gY9l6GAc8DWZRWmsvv2u7RjR57pwg7GQjPOg4fSVnU6gIVy_HVX1JsdNh5km8YBx1QubNFT2E0kRRqi3Eg3Dlj3DkFT6DB6uORIoine55QMeBC296MihDE8260fdTOSgPi231kiH7sI75cv63W8wAxRJVAxdN7Kojnk9MKeA28AfEN0wSI9Xvm5ja-R97-I-QX4LW28R0ZQWwQynVqA5QbBF7LMTrgDcJqjZ7i6C2-wGqdJ5BP4TPFFJlYTcTwgd8XrtpGPEhtHzM_Wnnf2XI973dW1HmRV9m057lx-3nhIcZjSOXxLfDtXsdh7PLeHYBvx0A-kzHKfjiQjQH4dqcNpXdRNoyzggHf_gidN18INDnL2U8lUNwR-Iz-QWB6vg50lXsvLXaEno7eqbEnNWv8RD5oZwNOlQjgz_OoQmkVzuizVbQ9ubck6AcvGf1GGNxXYc8hmGU3C6U_A_VvIDaRQsz74xGzLJEWmxP5zgX6tI3fd7OZrgpMS2-vokyLJ_PRTtvZds4Sut0n953lJaSiHkgrRwGti3Nr_sSUV2f8GwPMszj_foIL_psNsxTw8j_zSBym6m88_rYbNwbXyB-cCY_6eB2kfcOLGye1dhQietpLr8LHjfCr8weyuHbGaLtfqFaoRjRyQW2xKuqaVUXNFkO7o5p4UZV1J_uOBKtK2VPBGyUr4hVfLnTLGV-yqmiKJWuWLBeCdsu6KMWy5FQ3NSwZHaQ2uTGnQ-78fqFDGKltKrZaLYzsyITpHuPc0hmnSeA8XWu-TTlZN-4DLJnRIYYbStTRUPvuW90Zwqu3JvUuRm_avzhNEs71lR29-436CHw7rZ5OlJndqeV_BAAA___2-SZp">