https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101811
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Tobias Schlüter from comment #2) > Hi Jonathan, > actually I found clang's error message a lot more helpful, I just didn't > bother to write it explicitly, especially given that my compiler explorer > link shows it for everybody else to make the same observation. Well, you > came to a different conclusion comparing the two and so I was wondering why > I would find clang's message more helpful and you didn't. > > Here's clang's error message: > <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(); > > When I read that I know 1) there are two 'f's. GCC tells you this too, there are two locations, one on line 2 and one on line 6. > 2) the one on line 6 doesn't > match the one on line 2. That seems obvious from the fact there are two and GCC says "no declaration matches" :-) > 3) yet it ought to match (the) one in 'struct X'. > So I as s user am left with wondering "how does it not match" which is > sufficient to resolve the problem. I honestly don't see how GCC's error doesn't provide exactly the same information. It could be clearer, but all the same information is there. > Let me point to three things where gcc ends up making things harder to > understand in my opinion: > 1) clang uses (almost) complete sentences. One doesn't have to figure out > how the parts of the error message relate to then form a logical whole from > the set of "error" and "note"s. GCC's "error:" is a complete sentence too, it's just a lot more terse. > 2) "candidate" in gcc's error message appears to be a technical term or a It's the term used in the C++ standard for functions of the same name that are participating in overload resolution. The compiler isn't actually doing overload resolution here so maybe it's a poor choice of terminology that only makes sense from the compiler writers' perspective. > gcc-specific term, one has to make sense of what it means from the context > ("nothing matches -> oh, so this was a candidate for a match and this is > what 'candidate' means here" whereas clang's error implies directly that the > 'f' on line 2 was really close to the one on line 6. > 3) gcc's second note, which points to the struct declaration isn't really > helpful, it just floats in the ether for the user to make sense of. I would > go so far as to claim that it doesn't add any helpful information and thus > does more bad than good. I agree. I think this would be better than GCC's current diagnostic, and better than Clang's too: <source>:6:6: error: no declaration matches 'template<int> void X::f()' 6 | void X::f() | ^ <source>:2:10: note: non-matching declaration 'void X::f()' is not a template 2 | void f(); | ^ > Anyway, I'm well aware that the C++ frontend unfortunately doesn't get much > developer attention, That's not true at all. Over the past year it has more commits than all other GCC front ends combined, and more distinct contributors than any other front end.