Open
Description
The following valid program as explained here is rejected by clang and msvc. Demo
struct TestClass {
void testFinction() {}
static TestClass* ptr_;
constexpr static auto funcPtr = +[](){ ptr_->testFinction(); };
};
TestClass* TestClass::ptr_ = new TestClass();
int main() {
TestClass::funcPtr();
delete TestClass::ptr_;
return 0;
}
Clang says:
<source>:4:46: error: member access into incomplete type 'TestClass'
4 | constexpr static auto funcPtr = +[](){ ptr_->testFinction(); };
| ^
<source>:1:8: note: definition of 'TestClass' is not complete until the closing '}'
1 | struct TestClass {
| ^
1 error generated.
Compiler returned: 1