Issue |
134830
|
Summary |
Clang Rejects Valid CRTP Pattern with constexpr Virtual Function Accessing Derived Static Member
|
Labels |
clang
|
Assignees |
|
Reporter |
mohsen-micro
|
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;
};
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs