https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94529
Bug ID: 94529
Summary: Wrong error message for template member function
specialization
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: kunal.tyagi.3.1994 at gmail dot com
Target Milestone: ---
[Relevant godbolt](https://godbolt.org/z/trqEMV)
Snippet:
```
template <class T>
struct foo {
// the issue is const here
void bar(T& foobar) const { foobar = 0; }
};
template <> void
foo<int>::bar(int& foobar) { foobar = 9; }
```
GCC (trunk) gives the error message:
```
<source>:8:1: error: template-id 'bar<>' for 'void foo<int>::bar(int&)' does
not match any template declaration
8 | foo<int>::bar(int& foobar) { foobar = 9; }
| ^~~~~~~~
<source>:8:1: note: saw 1 'template<>', need 2 for specializing a member
function template
```
A better error message is reported by clang (3.5 onwards):
```
<source>:8:11: error: out-of-line definition of 'bar' does not match any
declaration in 'foo<int>'
foo<int>::bar(int& foobar) { foobar = 9; }
^~~
<source>:4:10: note: member declaration does not match because it is const
qualified
void bar(T& foobar) const { foobar = 0; }
^ ~
```