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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Cannot use a static constexpr/consteval member function to initialize a static constexpr member
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

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

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

<pre>
    I've noticed that consteval member functions exhibit very strange behavior—they can initialize static non-constexpr members but fail to work for static constexpr members.
Example ([Godbolt](https://godbolt.org/z/Ynn5xf78s)):
```cpp
struct A
{
    static inline constexpr bool test_constexpr() noexcept
    {
        return true;
    }
    static inline constexpr bool t_expr = test_constexpr(); // can't compile
    static inline constexpr bool test_consteval() noexcept
    {
        return true;
    }
    static inline constexpr bool t_eval = test_consteval();  // can't compile
    static inline bool t_non_const = test_constexpr();
};
inline constexpr bool t_expr = A::test_constexpr();
inline constexpr bool t_eval = A::test_consteval();
```
Output:
```cpp
<source>:8:34: error: constexpr variable 't_expr' must be initialized by a constant expression
    8 |     static inline constexpr bool t_expr = test_constexpr();
      |                                  ^        ~~~~~~~~~~~~~~~~
<source>:8:43: note: undefined function 'test_constexpr' cannot be used in a constant expression
    8 |     static inline constexpr bool t_expr = test_constexpr();
      |                                           ^
<source>:3:34: note: declared here
    3 |     static inline constexpr bool test_constexpr() noexcept
      |                                  ^
<source>:15:34: error: constexpr variable 't_eval' must be initialized by a constant expression
   15 |     static inline constexpr bool t_eval = test_consteval();
      |                                  ^        ~~~~~~~~~~~~~~~~
<source>:15:43: note: undefined function 'test_consteval' cannot be used in a constant expression
   15 |     static inline constexpr bool t_eval = test_consteval();
      |                                           ^
<source>:10:34: note: declared here
   10 |     static inline constexpr bool test_consteval() noexcept
      |                                  ^
2 errors generated.
Compiler returned: 1
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.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