<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/110359>110359</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang rejects valid program involving calling of a member function of an incomplete type inside class definition
</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 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.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VE2TozYQ_TXtS5cpkAyYAwd_jOeaw1btMSVEg5UIiUjCs5NfnxLY8djr5LYuIwkkvX6vv4T3qjdENeR7yI8rMYWzdbUTRghj7bhqbPtZfzsTdlZr-6FMjxehVYujs70TAyqPjv4gGajF5hOlFqZHYVoc_EViMwUUUtJ43e6lTBDy_ZEGC_kR2PYcwuiB74CdgJ162zZWh8S6Htjpb2Cnv97FD5m9ixxYBekR0t11LNLrf371wU0y4Dfy4aCF9wjlftnBi1UtBvLhNBkZlDXAtsAqlNb4MJ8rj9ej6IMISt5hgO1wDO534De05Rr9GN3tsJiCxW4y8rfgEPgRge0Xdy6GoNzPGGvgbz_TAL7HSOBm4GE9jw9k7i98B3wXcWebhj6-sr4if4VRJuAg1E393T9PkFclTxiILWkK9IrAl0OOwuQMpg9yXsXrMOeJF58zzn_HFfjB28lJAv4GfJdtge82BfAdknPWxcVAQ0NuTjPvUZlgURlph3HmGz5HQmDlF-eUN7aYbRHKA_7yoOL8i6Ygf3stLAe-i-LQ2EBxbqlTRkVMtN2zglh2xgb8V-ZkgtIYzoRSWx_LNOosjw9q85nC_5TKC5pP4VjGfB99lYzWB2B8XjvqXhU0kU6UB3aS0YFs3zrRhfj9xf31JiZm7B2Q7w_f3zHb8uIVqBz15OOT9CqcpyZRFtjp8P0d2El5P1E0GC8n5zDoCDqIP8ljOCuPH6T1urNuoDbBVVvztuKVWFGdlazMGc-LbHWut9UmLahiknGebTaSFaLomka2jci3rKSVqlnKNmnFtlnGK5YlTUflhlUtFUXalV0Bm5QGoXSi9WWIDW01U6uzLOV5tdKiIe3nvsvY3DWBsdiCXR0vrJup97BJtfLB3yGCCprqpXiWtuuf-7G5WH2JCSCF1nG2HYpbkXTXNJ0_mp_qRBmv2phCMS3uCbianK6fGvXieGkHYKdI7zqtR2cjrYdILIovNfsnAAD__xJ17yE">