https://gcc.gnu.org/bugzilla/show_bug.cgi?id=17459

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|2005-06-13 00:43:47         |2021-7-15

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Manuel López-Ibáñez from comment #5)
> The first error could be a bit nicer if it said why it is invalid. Clang
> does:
> 
> test.cc:3:16: error: reference to non-static member function must be called;
> did you mean to call it with no arguments?

I think we should just add a fix-it hint suggesting to add the ()


> but the thing is that this is not even a valid reference, so the error could
> clarify a bit more the problem, no?

I don't think mentioning "reference" here is a good idea at all, because that
means something specific in C++ (and completely unrelated to this).

I prefer GCC's "invalid use" wording. With a fix-it to add the () the error
would be fine.

If the function can't be called with no arguments, the fix-it would be wrong.
I'm not sure what we want to do in that case. Suggest the fix-it anyway, and
let the user figure out the next step?

Clang just says:

17459-c3.C:3:16: error: reference to non-static member function must be called

i.e. it omits the "did you mean to call it with no arguments?" part. So we
could do the same and just not provide a fix-it in that case.


> ISO C++ forbids taking the address of an unqualified non-static member
> function, say ‘&S::foo’ instead; or did you mean to call 'foo()'?

Maybe we should remove the -fpermissive extension that allows &foo as a
non-standard way to form a pointer-to-member. That simplifies the handling of
&foo, because we can just reject it instead of using a permerror. It's more
than 20 years since that was acceptable syntax.

And that could use a fix-it hint too, to suggest turning &foo into &S::foo.


> The last error is bogus, it should be the same as the first one.

Agreed.

Reply via email to