<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/97958>97958</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
lambda's operator() is non-constexpr function
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
Fedr
</td>
</tr>
</table>
<pre>
This program
```
static_assert(
[]<int I=0>() -> decltype([]{ return true; })
{ return {}; }()());
```
is accepted in GCC, MSVC and Clang 17, but Clang 18 complains:
```
error: static assertion expression is not an integral constant expression
2 | []<int I=0>() -> decltype([]{ return true; })
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 | { return {}; }()());
| ~~~~~~~~~~~~~~~~~~
<source>:2:5: note: non-constexpr function 'operator()' cannot be used in a constant expression
<source>:2:31: note: declared here
2 | []<int I=0>() -> decltype([]{ return true; })
```
Online demo: https://gcc.godbolt.org/z/nW74e4q9v
It is a modified example from https://stackoverflow.com/q/77431308/7325599
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8lM2OpDYQx5-muJSmZeymDQcO3T1DtIcoh0TJMTK4mnZibNY2s7s55NkjQ49mdtR72EMWIX8W_6r6ubCK0YyOqIXqBNVjoZZ09aHtSIei9_pL-9vVRJyDH4OagD0CO8KB3d51GpNKZvhTxUghAa-3Vdz0QJyNS_gBxCMD8ZS3eYMPIJ5Q02DTl5ny2mYrTxgoLcFhCguBOCHIR-DNTRER35iAPOXdF6Os-9I2IE53QzUR1TDQnEijcfjT-Qz8jD__-vsZldN4tsqNWMq82C_pZV7j4KfZKuMiiONdYQrBBxBH3GDgBsN4h_R5DhRjHpqIzidUDo1LNAZlcfAuJuXSG7PXZDmCPOOa9v_BEt_IP_37Hc-rhFglvvdQvnb-LX0Q5-iXMFBOVRw5iGOVCTufaOvdw4ovo8PL4oaVN3DpZwoq-fDiWeKgXCbfEy5xO3r1bfR3HIvyrecMWwXSeKVAP-S43lXbL84aR6hp8jmea0rzWpm8A96Nw7Abve69TTsfRuDdP8A794fc0_5j83wTXNsPKdekwslrczGkkT6rabaEl-Cnd7IxqeFv_0zhYv2n3eAn4N1H4J2Ue1EKVueh4FXVNIVuhW5EowpqS8mZOBykqItry1lJe61Z3w91dSiboWSHmglZib2Sur8UpuWM75lksqxEXdU7JhpFVcnrijHJyh72jCZl7M7a5ylnV5gYF2ob2VR1YVVPNq4XGeeOPuG6CZzney20-ZuHfhkj7Jk1McVXlWSSpdaqqdcKuIz4dQltf-69ciuWYNt3_E26Lv2NUPZw6x7m4P-iIQHv1rgi8G6L-7nl_wUAAP__UGGhjg">