[cfe-dev] Parse error for addrof overloaded function.

Enea Zaffanella zaffanella at cs.unipr.it
Tue Jul 23 13:30:00 PDT 2013


Hello.

When parsing the following program:
===================================
$ cat addrof-overloaded.cc
struct S {
   static void foo(int);
   static void foo(double);
} s;

typedef void (*PF)(int);

void test() {
   PF pf1 = s.foo;   // No error.
   PF pf2 = &s.foo;  // Error(?)
}
===================================

the following parse error is obtained:
===================================
$ clang++ -fsyntax-only addrof-overloaded.cc
addrof-overloaded.cc:10:12: error: cannot create a non-constant pointer to
       member function
   PF pf2 = &s.foo;  // Error(?)
            ^~~~~~
1 error generated.
===================================

Is this a known bug?

Enea.



More information about the cfe-dev mailing list