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

    <tr>
        <th>Summary</th>
        <td>
            Forward-declared consteval function is rejected for use in a template parameter's default value
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            rejects-valid,
            consteval
      </td>
    </tr>

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

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

<pre>
    GCC test: `g++.dg/cpp2a/consteval-defarg3.C`
```c++
consteval int foober();

int g(int = foober());
struct A { int i = foober(); };
template <int i = foober()> struct B { };
struct C
{
 consteval C(int = foober()) { }
};
int h(C = C());

consteval int foober() { return 42; }

int main() {
  A a;
  B<> b;
 g();
  h();
}
```
Diagnostic:
```source
<source>:5:19: error: non-type template argument is not a constant expression
template <int i = foober()> struct B { };
 ^~~~~~~~
<source>:5:19: note: undefined function 'foober' cannot be used in a constant expression
<source>:1:15: note: declared here
consteval int foober();
              ^
<source>:16:3: error: too few template arguments for class template 'B'
  B<> b;
  ^
<source>:5:36: note: template is declared here
template <int i = foober()> struct B { };
~~~~~~~~~~~~~~~~~~~~~~~~~~~        ^
```

Repro: https://godbolt.org/z/dPPE5TTnr
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVFGPozgM_jXmJWoFCVB44IHS9l5Xp_0DgRiaVZqgJMze3sP-9lOAodPOzs5Jd1FLwLH92f7scOfkoBEryI6QnSI--auxVfdNtFFrxI_qj6YhHp0HVhPI4wHoEehxLwagl24cKQ-70c7jC1c7gT23A9s3kMcQnyCuw8v86xbLRbpZEKk96Y1p0QItgJbAVpXlGY4HoEXYgZ0eVd9oO2-nzpOawOE4-5Tv1dmRwOG0mXi8jYp7JMCajyzOZHV8nB2_NV8PmjXawyom99Saj-PevK3Gd7fB4Aq0aGaz5n2mnxVwdm3RT1aTlL4m_VTSG5f6rr5GTmrCNxhCjsCaUIH2LhueOCJzqA_RbVivvC-fJ8kHbZyXHbD6ScOZyXa4ClmzfrIzsDoDVidl6D201tjwoo3e-R8jko0_bofphoFBR7TxhC8ccO0J_jVadE4a_b9wTiA7_1zWJ-Fq4zHskxbYS42C9JPuvDSaAD28Ah5Ix3UIuUUyORRE6t9F_4SWhH_2Fk1gp7hFQa5o8V9PGnlYkJ1_jZYDq9kDFd4Y0uP390w40htLOsWdux8CPRyBHn7TXh9ihyRZ_jbTzat0v8r6P_L88-P1vkyPjb48_8TRmhDn1fvRhZanF6CXwYjWKL83NlyffwO9iC9fztnXr9pGomKiZCWPsEryIinyvMiS6Foduq6nbSvatOhTmrRtVqZZ34sC2yKjLYtkRWPK4jQp4yRJk2RPWZEnWIoy7UohMIc0xhuXaq_Uyy1gR9K5CaucUppGireo3Hz_U9oprgdgdW-N9qgFUAq0AUotfsPOu90LV_Iu3ZorSLJTZKsAsWunwUEaK-m8u4N66RVWF2O_cyt2G2n3Bt0mRDqy4IWxMTaMxjIZG60jt_yGfp6h0AA9n5QnL1xNGE1WVU9ll_46tfvO3IBeQjzrthutCTBAL3NFHNDLXJR_AgAA__82dxPt">