<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/83424>83424</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang rejects valid program involving member access operator with incomplete type CWG 1836
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
ranaanoop
</td>
</tr>
</table>
<pre>
The following valid program as explained [here](https://stackoverflow.com/a/78080150/12002570) is rejected by clang and msvc. [Demo](https://godbolt.org/z/Yhc8MeWW6)
```
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
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE1v8zYT_DXryyIGRUqWdNDBH9F7eoEeHiDoqaCotc2WIgWScp701xeU5cZ20t5q2PyAF7Mzu8uRIeiTJWqg2EFxWMkpnp1vvLRSWufGVef6j-bHmfDojHHv2p7wIo3ucfTu5OWAMiD9HI3UlnqEYncmT1AcgFfnGMcAYgu8Bd6GKNUf7kL-aNz7WrkBeCuBt2XFKpYVDHibccZ4UTLgNeqAnn4nFanH7gOVkfaE0vY4hItap0QHGtx3iU6u75yJa-dPwNs_gbe_nlX1f3p72wCvgR2AbZd1w5bvfA3RTyriDwpxb2QICOXu-g_ixekeI4XYaquidhZ4lWimkPJwiwpRRq0-EYBvcYz-NxA3IOVsiPRz9LdYOUWHx8mqX6JHEAcEvrv24poByt0M8QLi9Wt-EDtM-W_4D-d5feDyeRFbENuEO-e09H5PekG-h9E24iD1vexF8xPmIuUJBLEnQ5G-Y3AX5ClO3iJ70PNdq67rfh6KID9mtH9uLIh9cJNXBOIVxDZPvw2ILZL3zqfDQENHHqVSFAJqGx1qq9wwzqTjx0gIvLwrUXmjjJgjlHvE_7q1OH9SKihev9WVgdhWSY11kdLe01FbnSDRHZ8FpBdmXcS_VU42aoPxTKiMC-mhJ5nl4UFsNjP4t5fyhWV2LTOeyJKXkfr10j03jNqQX7pOfaKcPTVw1Teir0UtV9RkJat5lpUsX52bquwKqinnm7LIj4pnJSuPoi6rvBO86NVKN5zxnHFeZ4Jleb7mWcdYUbC6lrLmdQc5o0FqszbmMiS3WOkQJmoqkfN8ZWRHJsy2yPnsPsB5ckjfpPiXbjoFyJnRIYZPhKijoeY6l1f7Ck92qe3FmUuq7uPMuTEVx3l81_H8Zfj2b__DrBKb1eRN82R3Op6nbjHURGTZXkbvEgHg7awrAG9naX8FAAD__zizwxM">