[Bug c++/23194] New: Unhelpful diagnostic for incorrect pointer-to-member function syntax

redi at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Tue Aug 2 06:38:00 GMT 2005


Given:

struct A {
    void mf() {}
};

int main()
{
    void (A::*pmf)() = &A::mf;
    A a;
    a.*pmf();   // should be (a.*pmf)();
}

mainline GCC says to use .* or ->* to use the PMF,

pfm_diag.cc: In function 'int main()':
pfm_diag.cc:9: error: must use '.*' or '->*' to call pointer-to-member function
in 'pmf (...)'

This is unhelpful if you don't know the right syntax, because the correct
operator _is_ present, but the compiler is complaining about the expression to
the right of the operator.  Maybe it would be better if the error message had a
complete example after it:

pfm_diag.cc: In function 'int main()':
pfm_diag.cc:9: error: must use '.*' or '->*' to call pointer-to-member function
in 'pmf (...)', e.g. '(a.*f) (...)'

-- 
           Summary: Unhelpful diagnostic for incorrect pointer-to-member
                    function syntax
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: redi at gcc dot gnu dot org
                CC: gcc-bugs at gcc dot gnu dot org


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



More information about the Gcc-bugs mailing list