<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/117321>117321</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Immediate invocations in constexpr initailizers are evaluated twice
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
groundswellaudio
</td>
</tr>
</table>
<pre>
It seems that immediate invocations in constexpr initailizers are evaluated twice, once on evaluating the decl, and again on Sema::HandleImmediateInvocations (this doesn't happen if the var is within a consteval function). Strictly speaking, not a defect, but it's kinda wasteful?
```cpp
consteval int foo(int* b) {
return *b; // Evaluation errors are emitted twice
}
constexpr int a = foo(nullptr);
```
https://godbolt.org/z/7ec5bsK9e
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJykk8GOozgQhp_GXEodgUlCOHBIbxZttMd-gsIuoKaNjewime6nH5Gk1Zm5joRAYLv-r_76wZR48ESN2r2q3SnDRcYQmyGGxdt0JedwsRyyLtiP5iyQiKYEMqIATxNZRiFgfwkGhYNPwB5M8Eno5xyBPQuy40-KCTAS0AXdgkIW5MqGlP4HgjcEwX8tsR9ARgJLxq3L6C3ggOzXPW80oSqPqjz-h946On8hnJ8IlD7IyAlsoOSVrgRGnGfywP2t8gUjcIIry8ge8IF7QQf94s1aQ-l6A28S2Yj7gDQTvrMfVhofBBAs9WRkfe8WARalqwTv7C3CFZNQvzhVtqDyk8qPj_s-v19mnu9fvmXZC_QhKH1gL0ofoVO6BlW93jcCAESSJXpQ-tip8hWUbpVu4d-HZat7MYYvjyeWb4fv6tXpGeZ5QGs_qjw9APzi3CxR6fom8zv6c4lRZE7rKG4kQ7BdcLIJcVC6_VS6rcjsuvR_TZltSluXNWbUFFWpdVUdqn02Nja3FWKxrbEvDwfcbvu63ve21nbfmRz7jBud621RaF3ootrtNrTba1N1h64wldXWqG1OE7LbOHeZVu2MU1qoKVadInPYkUu3YGttHK4T1GvGY7MeeOmWIalt7jhJ-i4hLO72N9xP7E5w_vucZ0t0zR-WsYxLtzFhUrpd1R-PlzmGH7d0tbduktLto6FLo38FAAD__yDJMrA">