Issue |
110359
|
Summary |
Clang rejects valid program involving calling of a member function of an incomplete type inside class definition
|
Labels |
clang
|
Assignees |
|
Reporter |
ranaanoop
|
The following valid program is rejected by clang and msvc but accepted by gcc. [Demo](https://godbolt.org/z/qGaxc1Ga5)
```
struct TestClass {
void testFunction() const {}
static TestClass* ptr_;
constexpr static auto funcPtr = +[](){ ptr_->testFunction(); };
};
TestClass* TestClass::ptr_ = new TestClass();
int main() {
TestClass::funcPtr();
delete TestClass::ptr_;
return 0;
}
```
Clang says:
```
<source>:18:46: error: member access into incomplete type 'TestClass'
18 | constexpr static auto funcPtr = +[](){ ptr_->testFunction(); };
| ^
<source>:15:8: note: definition of 'TestClass' is not complete until the closing '}'
15 | struct TestClass {
| ^
```
[expr.post#expr.ref](https://eel.is/c++draft/expr.post#expr.ref-4) and [CWG 1836](https://cplusplus.github.io/CWG/issues/1836.html) makes this well-formed.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs