This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15684] New: Pointer to member function called on incomplete type should diag
- From: "gianni at mariani dot ws" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 May 2004 16:36:29 -0000
- Subject: [Bug c++/15684] New: Pointer to member function called on incomplete type should diag
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Leor Zolman posted this example on comp.lang.c++
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=due8b09cd2lp3kip4ivtcrn2m3nu6jvmuu%404ax.com
It seems according to the standard that the code below is illegal. However it
is accepted by all compilers I know of. I verified that 3.4.0 accepts the code
below.
#include <iostream>
using std::cout;
using std::endl;
class A;
class B {
public:
typedef void (A::*ftype)();
void CallIt(A *ap, ftype f)
{
(ap->*f)(); // Is this legal with ptr to incomplete type A?
}
};
class A
{
public:
void method_for_B() {
std::cout << "In method_for_B...()" << std::endl;
}
};
int main()
{
void (A::*fp)() = &A::method_for_B;
A a1;
B b1;
b1.CallIt(&a1, fp);
return 0;
}
--
Summary: Pointer to member function called on incomplete type
should diag
Product: gcc
Version: 3.4.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gianni at mariani dot ws
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15684