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

    <tr>
        <th>Summary</th>
        <td>
            ICE on a lambda that uses deducing this and parameter pack capture
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    ```cpp
template<int I>
struct constant {};

template<typename ...Args>
auto fast_tuple(Args... args)
{
 return
        [...args = args]
        <typename Self, int I>
 (this Self &&self, constant<I>)
        -> decltype(args...[I])
    {
 return args...[I];
    };
}

int main()
{
    auto r = fast_tuple(1, 2.0);
    auto &&ll = r(constant<0>{});
}
```

https://godbolt.org/z/rhzWfns3K

I tried to reduce this code snippet even more but I haven't managed to do that:
* If you change the return type of the lambda (`-> decltype(args...[I])`), it stops crashing
* If you remove deducing this (`this Self &&`), it stops crashing
* If you remove `constant<I>` and start using non-deduced index, it stops crashing

Somehow the synergy of these three features produces surprising crash-causing combo.

Funnily enough it also crashes the latest version of gcc
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUVE-v-jYQ_DTLZUXkOCTAIQd4PCTU4-_QY-XYS-LWsSP_4Vfep6-cQPtAqqoiEAjPzszObixC0L0laqE-Qn1aiRQH59uge_H8rDqn7i00bHnLaQJ2iDRORkSC6kPbiBeoPoEdQvRJRpTOhihsRNgeYXuC6gjs8FoU7xNZMRIWRXHwfVjqRYoOryLE32KaDAHf5bOiKFBkDN9nnm1mQ08xeZt_PV5QH4uiyDiE6rQU1KfvgG-qP8hcgX_gN-8IfBcHHeYzBN4Ab8ID9mwIqo8ZPRt58q6h-kRF0mR24DuxWIb6eMkG_sa-GMc31BzRgnrmtT0tqWWPo9AW-O4lAUSc8_Jzvy-pldk0L1jGVy_gpS9j5hoPfPetNZZbWyb2rHuYeM5-MTTEOAWoDsDPwM-9U50zsXC-B37-An72w9evVxuqXxb4BaPXpDBbJZUk4RyzdIowWD1NFJFuZHF0nrBLES84iBtZ4NvcuRX9Uq0cxkHErMwOwA94ueLdJZSDsH1mpWe4eRLorvNfRoydEnm60LD_nlUzh5ZXI2KIbgoovQiDtv2rqKfR3QhV7kjbfulpEXnfov_LmR-yt4VrGAqrMEThI6aQBa2z61mdFGqr6M9_FWCHH26kwf2c8wh3S76_P-IJOTdPhFcSMXkKOHmXSQOG5CevZ62ZbS3Foizd2LliYT4na7W5I1mX-iHrCxPcUkDhMYBIIeKNfNDOZt1eypVqK7Wv9mJFbbmtWbnlbFuuhnYvuSLOm06pRl5Fc62bfVPXYlPyrqO6XOmWM16zptyWm3pTlcW-ZHJTc8FEvb8qTrBhNAptCmNuY17LlQ4hUVtuNvWGrYzoyIT5vuPc0k-cT4HzfP35Nhetu9QH2DCjQwz_0EQdDbWXj090FsVzsfJKYgoU3nYhz2sSXowUyeMk5B8oxZQzXiVv2reHSMchdYV0I_BzFnx8rSfvficZgZ9nmwH4-dHHreV_BQAA__9uhsWI">