<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/114234>114234</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang: immediately-invoked lambda in template arg is not implicitly constexpr
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
elbeno
</td>
</tr>
</table>
<pre>
An IILE as a template argument inside some other templates; this is the smallest SSCCE I could find.
```cpp
template <auto Arg>
auto g() { return Arg; }
template <typename>
auto f() {
[]<typename>() {
// lambda is not treated as implicitly constexpr?
g<[] { return 123; }()>();
// explicit constexpr works
// g<[] () constexpr { return 123; }()>();
}.template operator()<int>();
}
int main() { f<int>(); }
```
produces:
```console
<source>:8:9: error: no matching function for call to 'g'
8 | g<[] { return 123; }()>();
| ^~~~~~~~~~~~~~~~~~~~~~~
<source>:6:20: note: while substituting into a lambda expression here
6 | []<typename>() {
| ^
<source>:14:14: note: in instantiation of function template specialization 'f<int>' requested here
14 | int main() { f<int>(); }
| ^
<source>:2:6: note: candidate template ignored: invalid explicitly-specified argument for template parameter 'Arg'
2 | auto g() { return Arg; }
| ^
1 error generated.
```
https://godbolt.org/z/x6heGf38x
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVd1uozoQfhrnZtQI7BCSCy6SNDmqdO72CQyegM8am2MP3WYvzrMfGRJC26y0lRZVUDkz833f_FmGoGuLWLBsz7Lnheypcb5AU6J1i9KpS7Gz8PLy9xFkAAmEbWckIUhf9y1aAm2DVgjBtQiOGvSTTWBiD9ToADoANQihlcZgIPj27XA4wgtUrjcKztqqJUueWbK7vtfJ-Fd13XgywTJxkD052PmaieP443BQM75hfAss34NH6r0dbfbA8ud58HkounRoZYvvQ53vocZTAIAxPx98PtoxfmL8BEa2pZJRtXUE5FESqpg_3XZGV5rMBSpnA-Fb55k43VHiUzNxGNHmYlIubmIG1Ameif17_ysJfBux7kjww_nv4aHxHHMUdff6MgmWPy-nLLsOvSTnb3YHbemz24caaUvQSm1nNT1_dp1V9tYw8yCdd6qvYhfuHjeXs8EZvJ6KQ3C9r4ayit2Gid2WiR2g987Hf6yDVlLVaFvDubcVaWfh7DxU0hggB4znNeP5PQ0bYPkB_kxV55FYdvzv4fNQyZqJHU9GBYTx-6PRBiH0ZSBNPUVB2pIDeevbWHUMIQps0OOdx3rg8VuT8In17GHZ8SHVdHV7TVy1jfuFpCUth4y78z37U4-FDistjf452jCez7slB4__9hjiDM70pKuB31db7RfKfqWJX0swKaqkVVpF1hN9XVvnUY16X6XRahpec3kaxJ11XCC3lRvbbvLupJctEvqoO668eQ_ygenvLsi7tklOOk4A1GjjHOO0qB9NXEPUDeM2LJXaqdIZWrrI6fST8dPbusG_zmLztlCFUFuxlQss0lwkfLvOeLZoijLLlMh5pXKRyrTME56IVG3wnGyzbFOWC13whK_SRCSpyDKeLTlfZynKrVJqlapkw1YJtlKbpTGvbcRe6BB6LNJ0xcVqYWSJJgy3HeeVkbZmnMeLzxfR4ans68BWidGBwj0EaTJYHAbzWKW2RaUlobk8afvqvqOadr59d0Xe7oBHi3_Re1N8SJmmpi-XlWsZP0X06-ep8-4frIjx06AmMH66Cnot-P8BAAD__32HOxo">