On Thu, Jul 25, 2013 at 1:49 AM, Enea Zaffanella <span dir="ltr"><<a href="mailto:zaffanella@cs.unipr.it" target="_blank">zaffanella@cs.unipr.it</a>></span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello Richard,<br>
<br>
I am afraid there is still something unclear to me<br>
(I may be missing something obvious ...):<div class="im"><br>
<br>
On 07/23/2013 11:13 PM, Richard Smith wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
On Tue, Jul 23, 2013 at 1:30 PM, Enea Zaffanella <<a href="mailto:zaffanella@cs.unipr.it" target="_blank">zaffanella@cs.unipr.it</a><br></div><div class="im">
<mailto:<a href="mailto:zaffanella@cs.unipr.it" target="_blank">zaffanella@cs.unipr.it</a><u></u>>> wrote:<br>
<br>
Hello.<br>
<br>
When parsing the following program:<br></div>
==============================<u></u>__=====<div class="im"><br>
$ cat addrof-overloaded.cc<br>
struct S {<br>
static void foo(int);<br>
static void foo(double);<br>
} s;<br>
<br>
typedef void (*PF)(int);<br>
<br>
void test() {<br>
PF pf1 = s.foo; // No error.<br>
PF pf2 = &s.foo; // Error(?)<br>
}<br></div>
==============================<u></u>__=====<div class="im"><br>
<br>
the following parse error is obtained:<br></div>
==============================<u></u>__=====<div class="im"><br>
$ clang++ -fsyntax-only addrof-overloaded.cc<br>
addrof-overloaded.cc:10:12: error: cannot create a non-constant<br>
pointer to<br>
member function<br>
PF pf2 = &s.foo; // Error(?)<br>
^~~~~~<br>
1 error generated.<br></div>
==============================<u></u>__=====<div class="im"><br>
<br>
Is this a known bug?<br>
<br>
<br>
It's not a bug. You can't do that.<br>
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_closed.html#61" target="_blank">http://www.open-std.org/jtc1/<u></u>sc22/wg21/docs/cwg_closed.<u></u>html#61</a><br>
</div></blockquote>
<br>
Why isn't clang issuing a similar diagnostics for the first line:<div class="im"><br>
<br>
> PF pf1 = s.foo; // No error.<br>
<br></div>
Reading 13.4 in the C++03 standard, there seems to be no distinction of whether or not the address-of operator is explicitly used (it is meant, for non-instance methods):<br>
<br>
===================<br>
A use of an overloaded function name without arguments is resolved in certain contexts to a function, a pointer to function or a pointer to member function for a specific function from the overload set.<br>
[...]<br>
The overloaded function name can be preceded by the & operator. An overloaded function name shall not be used without arguments in contexts other than those listed.<br>
===================<br>
<br>
Which is the bit of the standard saying that the thing is legal if the `&' is left implicit?<br></blockquote><div><br></div><div>Hmm, I missed that part of your question. I think that is a bug; we should reject both examples.</div>
</div>