http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59931

            Bug ID: 59931
           Summary: Wrong wording of diagnostic about imaginary "member
                    function type"
           Product: gcc
           Version: 4.8.2
            Status: UNCONFIRMED
          Severity: minor
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: frankhb1989 at gmail dot com

Case:

class C
{
public:
    void f()
    {
        void (C::*pf)() = f;
    }
};
int main(){}


a.cc: In member function 'void C::f()':
a.cc:6:21: error: cannot convert 'C::f' from type 'void (C::)()' to type 'void
(C::*)()'
    void (C::*pf)() = f;
                      ^

In short, there is no type like 'void (C::)()' in modern C++, at least in ISO
C++. The member 'C::f' here should have type 'void ()'(if it makes sense), just
as a non-member function type. The reason should be determined by the
difference between pointer types and pointer to member types, and no conversion
like function-to-pointer takes effects in it.

P.S.
Clang++ 3.0 complains about this as:
"error: cannot initialize a variable of type 'void (C::*)()' with an rvalue of
type '<bound member function type>'".
And Clang++ 3.2's:
"error: cannot initialize a variable of type 'void (C::*)()' with an rvalue of
type 'void'".

Reply via email to