This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
weird stuff with pointers to members, casts
- To: gcc-bugs at gcc dot gnu dot org
- Subject: weird stuff with pointers to members, casts
- From: dvv at egcs dot dvv dot ru (Dima Volodin)
- Date: Thu, 30 Mar 2000 07:44:49 GMT
- Organization: Huh?
# cat mp.cc
#include <iostream>
struct C;
typedef void (C::* VMCP) ();
struct C {
static int counter;
VMCP f () {
counter++;
cout << this << "->f ()" << endl;
return (VMCP)&C::f;
}
};
int C::counter (0);
int
main () {
C c;
VMCP (C::* p1) ();
p1 = (VMCP (C::*) ()) c.f ();
if (c.counter != 1) {
cerr << "C::f called " << c.counter << " times" << endl;
return 1;
}
}
# ./mp
0x80479cb->f ()
0x80479cb->f ()
0x80479cb->f ()
0x80479cb->f ()
C::f called 4 times
#