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

Richard Smith richard at metafoo.co.uk
Tue Jul 23 14:13:42 PDT 2013


On Tue, Jul 23, 2013 at 1:30 PM, Enea Zaffanella <zaffanella at cs.unipr.it>wrote:

> 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?
>

It's not a bug. You can't do that.
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#61
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130723/ce342824/attachment.html>


More information about the cfe-dev mailing list