This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: 2.95.1 fails to complain
- To: jdonner at schedsys dot com
- Subject: Re: 2.95.1 fails to complain
- From: "Martin v. Loewis" <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Wed, 15 Sep 1999 08:35:03 +0200
- CC: gcc-bugs at gcc dot gnu dot org
- References: <37DE5F55.2B394164@schedsys.com>
> 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 qualifiedid 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 expression
# 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