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

    <tr>
        <th>Summary</th>
        <td>
            Clang Rejects Valid CRTP Pattern with constexpr Virtual Function Accessing Derived Static Member
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          mohsen-micro
      </td>
    </tr>
</table>

<pre>
    When compiling the following CRTP-based code in C++20 mode, Clang rejects the code with an error about missing static member `Id` in the derived class, while GCC and MSVC accept it without issues.

Please look at [this godbolt code](https://godbolt.org/z/Pf4W9obqv).

Here is the code:
```
struct Base {
    virtual constexpr int get_id() const noexcept = 0;
};

template <typename Derived>
struct A : Base {
    constexpr int get_id() const noexcept final {
        return Derived::Id; // Clang error: "no member named 'Id' in 'B'"
    }    
};

struct B : A<B> { // Note: A<B> instantiated here
    static constexpr int Id = 66;
};
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyMU8Fu4zYQ_ZrRZRCDISXLPuggyes2hy2C3SJ7LChybLGlSJeknE2_vqCswE1ONQxQAjXvvXkzT8Zozo6ogaqD6lDIOY0-NJMfI7mHyajgi8Hrt-bHSA6Vny7GGnfGNBKevLX-Nb_1335_fhhkJI3Ka0LjsAfeAe84w8lrAt5jb6U7Y6A_SaW4ACzfvpo0onRIIfiAcvBzwsnEmHFjkskonGgaKCBs2ZOGLcvwuVxTMNdMaWWMmeF1NJbwl75H6TR-_f7So1SKLglNWngytolxprgB1gJrny3JSGi9_wtlQqi6NJqIZ68Hb9MiEKoD8N2Y0iWCaIEfgR_X-40PZ-DHf4Afn0_lj70f_r4C36_Yv1IgNPdOczVrYcvWP2tjCrNK2GUJUHfAWkTEqwlplhaVdzHRz0tA4xKeKf1hNPAd8P3tCp2nn0t3IA7IQGQAqA_rA2sTTRcrEyGIPr1dyMmJ8HAzDcSXu4AWQbSfZfx_-pNx0v6nMv8CpTm4O1sLon3SIDq8ObhuwzL0TA6cO_8-6CxUI_D6SQOv87iB1x3wGjhfOaA-LMfHjt8NXfppQfQdiC9Z2Tvrbz7RhzvjYpIuGZlI40iBVvx18z6a8KQXq7fbz16_z7TQjdB7sZcFNY91WT6yLRP7YmyU0DtV8Zrx7U4pudvxR06cV1tR6u2geGEaznjFSrZj-0pU-82p3otyx0-qVDWrSgklo0kau7H2OuXFK5ZFbh5FuROssHIgG5cUc66yt9mr6lCEJhc8DPM5QsmsiSneIZJJlprbKL6twXyR1ugl0fgsU6LgbhG9W_GyLuhxdioZ77BVim6BXeeN32_2fV3mWczBNp8CZNI4DxvlJ-DHLGc9Hi7BZxnAj7ecAj-uHV4b_m8AAAD__z_wdHY">