<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/111283>111283</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Crash when passing a lambda to function in `decltype`, or `no viable conversion from` lambda to itself
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          HolyBlackCat
      </td>
    </tr>
</table>

<pre>
    The following code sometimes segfaults and sometimes gives a nonsensical error.

v1:
```cpp
void foo(auto &&) {}
auto bar(auto &&a) -> decltype (foo([]( auto && ... ){})) {}
struct A {};

int main()
{
    bar(A());
}
```
v2:
```cpp
namespace N
{
    void foo(auto &&) {}
    auto bar(auto &&a) -> decltype (foo([]( auto && ... ){})) {}
    struct A {};
}

int main()
{
    bar(N::A());
}
```

Here's v1 segfaulting on Clang 19: https://gcc.godbolt.org/z/1Ycq96r6b

And v2 emits this error:
```none
<source>:10:5: error: no matching function for call to 'bar'
   10 |     bar(N::A());
      |     ^~~
<source>:4:10: note: candidate template ignored: substitution failure [with a:auto = N::A]: no viable conversion from '(lambda at <source>:4:41)' to 'N::(lambda at <source>:4:41)'
    4 |     auto bar(auto &&a) -> decltype (foo([]( auto && ... ){})) {}
      |          ^  
```
---
There's some variance here. My local Clang 19 (as opposed to godbolt) segfaults on v2 instead, and emits this error on v1.

Clang 18 on godbolt emits this error instead of segfault on both v1 and v2.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VUuPnDgQ_jXuS6mRMTSPA4d-pJXL5pTLHo0pwLvGZm3To9lDfvvKPLo7k8lqcomEwLLr8dXnrwrunOw0YkUOJ3K47Pjke2Orz0a9nhQXf5-539Wmea2-9gitUcq8SN2BMA2CMwN6OaADh13LJ-UdcN087Xfyhg44aKMdaicFV4DWGhsReiH0uLxvMUnWJcno8ohxXA-NbKA1hrCCT94AY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