2.95.1 fails to complain
Martin v. Loewis
martinATmira.isdn.cs.tu-berlin.de
Tue Sep 14 23:55:00 GMT 1999
> When there is a second non-static member Create
> with a different signature declared, 2.95.1 correctly
> complains. Without the second, irrelevant (that I can
> see) Create function 2.95.1 takes the bad syntax without
> comment. Is this a bug?
No. A pointer to a static member function is a pointer-to-function,
not a pointer-to-member (8.3.3/3). Now, 5.3.1/3 says
# A pointer to member is only formed when an explicit & is used and
# its operand is a qualifiedÃÂid not enclosed in parentheses.
which justifies the error gcc is giving when the qualified-id is a
non-static member. In addition, 5.3.1/5 explains
# The address of an overloaded function (clause 13) can be taken only
# in a context that uniquely determines which version of the
# overloaded function is referred to (see 13.4). [Note: since the
# context might determine whether the operand is a static or nonstatic
# member function, the context can also affect whether the expresÃÂsion
# has type "pointer to function" or "pointer to member function." ]
Taking this all together: There is no requirement to put the & in
front of a static member, as no pointer-to-member is formed. However,
if the qualified id identifies an overloaded function, and some of the
functions are non-static members, you need an & - even if overload
resolution will select the static member.
Regards,
Martin
More information about the Gcc-bugs
mailing list