This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/15684] 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 20:49:01 -0000
- Subject: [Bug c++/15684] Pointer to member function called on incomplete type should diag
- References: <20040527163621.15684.gianni@mariani.ws>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From gianni at mariani dot ws 2004-05-27 20:48 -------
About Leor's citation on virtual's being difficult. It seems like it's not so
hard after all. BTW I also tried this example where B::CallIt was in a
different translation unit and it all worked fine. So, while I can agree that
you might need different implementation for pointer to virtual member function
and regular member functions, it seems like gcc at least has no such issue.
(tested on 3.4.0).
#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:
virtual void method_for_B() {
std::cout << "A In method_for_B...()" << std::endl;
}
};
class AX
: public A
{
public:
virtual void method_for_B() {
std::cout << "AX In method_for_B...()" << std::endl;
}
};
int main()
{
void (A::*fp)() = &A::method_for_B;
AX a1;
B b1;
b1.CallIt(&a1, fp);
return 0;
}
oh - here is the link again, hopefully without wrapping
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&c2coff=1&threadm=3ACC2828.45CA0D3C%40dresdner-bank.com&rnum=1&prev=/groups%3Fq%3Dg:thl1416673164d%26dq%3D%26hl%3Den%26lr%3D%26ie%3DUTF-8%26c2coff%3D1%26selm%3D3ACC2828.45CA0D3C%2540dresdner-bank.com
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15684