<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/64777>64777</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[C++20] [constexpr] virtual member function template specialisation compilation error
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
pkeir
</td>
</tr>
</table>
<pre>
The C++20 code below fails to compile with Clang trunk (GCC and MSVC compile fine). Removing either both `constexpr` qualifiers; or the `virtual` specifier will remove the error.
```cpp
template <typename T>
struct Foo
{
constexpr
virtual
void m() { }
};
template<>
constexpr
void Foo<int*>::m() { }
```
The invocation and error message are below:
```
$ clang++ -std=c++20 -c test.cpp
test.cpp:15:17: error: explicit specialization of 'm' after instantiation
void Foo<int*>::m() { }
^
test.cpp:15:6: note: implicit instantiation first required here
void Foo<int*>::m() { }
^
1 error generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJycVMmS4zYM_RrogmqXTGqxDjp4aeeUSzKVO0VBFjMUqSGh7pl8fUpL1BnXnNrloriAwMN7BFSM5uGIasgvkN8SNXHvQz1-JROSxrc_6i894RXEBcRFpKh9S9iQ9e_YKWMjskfth9FYwnfDPV6tcg_kMLmvCOL02_WKyrX4-59_XXfDzjgCUR3wDxr8m3EPJMM9BWw89whFqr2LTN_HAEWK3yZlTWcoRJAX9AG5p9nozQSelJ1N4kh6McF3Yy2G2S0tdhSCDwdIb5Cet7FI178ex3WHaRitYkKQV_4xklMD4ReQr7ieRw6TZrx7v21AedlmiDvUfWfD9bH2psUBxAlEhcvV8rY7us05bZY_owF5_YDwHGXxefce5NU4BnEG-QryDPL8FOgp5_8TMQtr3JvXio13i0oLWzhQjOpBqMIm9ez5VwxuS5GhnlVfHwm-RG5B3vT-Zl40MkU-6HHcc1yXIM_HfB5KkOc1-jL5PlqjDa-6Kmv-WSH6DkGUA4gSVccU0LjIyrFZjj_FDEL--mtMxYzE-VmIM5phQ_RTROxMiIyBvk0mUIs9Bfocivm3IzluOjzIUVBM7eGJ96StZVvJSiVUH4tKiEqcqiLp6zQ7Cpm1J9l0RSlPjSqqrBJtq7NW6lxlialFKmR6OpbHUhxlfhC6KDJRlEWXdjpvUshSGpSxB2vfhoMPj8TEOFFdZGVZJlY1ZOPSK4Rw9I7LIQgxt45Qz3demukRIUutiRw_vLBhuzSZvZVAfkPILx-lnt_20hloaChgNzm98LxX6H8PIq78rw1lnS-cJVOwdc88xpltcQdxfxjup-ag_QDiPuPZPi9j8H-TZhD3JYsI4r5k-W8AAAD__ywAheY">