public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/82334] improve list of candidates for a member definition that doesn't match declaration
       [not found] <bug-82334-4@http.gcc.gnu.org/bugzilla/>
@ 2021-08-09  9:41 ` redi at gcc dot gnu.org
  0 siblings, 0 replies; only message in thread
From: redi at gcc dot gnu.org @ 2021-08-09  9:41 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-08-09  9:41 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-82334-4@http.gcc.gnu.org/bugzilla/>
2021-08-09  9:41 ` [Bug c++/82334] improve list of candidates for a member definition that doesn't match declaration redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).