<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/54744>54744</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
consteval calls in default args
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
urnathan
</td>
</tr>
</table>
<pre>
Consteval calls in default args do not work
```
consteval int here() { return 5; }
void error(int location = here()) { }
void bob () { error(); }
```
The problem here is we markused the consteval fn, which causes us to emit an error about taking the address of the consteval fn. I patched up EvaluatedExprMarker, called from Sema::CheckCXXDefaultArgExpr to skip such consteval calls, but we then ICE in code emission, trying to emit a consteval fn body.
https://bugs.llvm.org/show_bug.cgi?id=5810 seems relevant, as that's mentioned in the comment in CheckCXXDefaultArgExpr:
// FIXME: We should really be rebuilding the default argument with new
// bound temporaries; see the comment in PR5810.
// We don't need to do that with block decls, though, because
// blocks in default argument expression can never capture anything.
5810 includes the ominous note:
One could imagine rebuilding the AST nodes with new CXXTemporary pointers, although that's going to require a lot of code :(
Notice that because of __source_location(), which is different on every evaluation, we can't just morph the original defaultArgExpr as is held in the ParamDecl. We have to clone and evaluate at each use, I think.
(this default arg pattern is used in the source_location header to get the location corresponding to the caller of the source_location ctor, not the location of the ctor itself)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx9VdFu6jgQ_ZrwMloEIRT6wEMLrdSHu3u1t9L2rXLiIfHFsbO2U5a_32OHtMBdrRRBnNgzZ845MymtPG221vjAH0JTJbT2pAxJ3oteBxKu9iQtGRvoaN0hm-2y2UN2NztfaVl9nlcmUMOOs3yd5feUrR7JceidoWW2eMR6N5z4sEoSO2cddsZD2lYiKGsoW-wuIoxBrg-WtqSLDGOcuP8yyQ3K14apc7bU3KYMpDwdmVrhDr1nSQHvvyrZmyzf0rFRVQNWsMFT7ylY4laBFjNkJVHaPlAQB2XqFEFI6dh7svtfAk6JX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