https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82334
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2017-09-27 00:00:00 |2021-8-9 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- This example is from PR 101811 struct X { void f(); }; template<int i> // this line should not be here void X::f() {} GCC is pretty bad here: <source>:6:6: error: no declaration matches 'void X::f()' 6 | void X::f() | ^ <source>:2:10: note: candidate is: 'void X::f()' 2 | void f(); | ^ <source>:1:8: note: 'struct X' defined here 1 | struct X { | ^ But Clang is no better: <source>:6:9: error: out-of-line definition of 'f' does not match any declaration in 'X' void X::f() ^ <source>:2:10: note: member declaration nearly matches void f(); ^ It seems to give up on noticing why the candidate doesn't match and just says "nearly matches" as a generic fallback. To fix this bug will need a list of things to check for. Did it fail to match because one is cv-qualified and the other isn't? Maybe one is ref-qualified and the other isn't? Maybe one is a function template and the other isn't? Maybe the number or type of parameter (or template parameters) doesn't match etc.