Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!sri-spam!ames!ucbcad!ucbvax!decvax!decwrl!labrea!uluru!calder From: calder@uluru.UUCP Newsgroups: comp.lang.c++ Subject: Possible cfront v1.2 bug. Message-ID: <1728@uluru.STANFORD.EDU> Date: Thu, 4-Jun-87 19:17:06 EDT Article-I.D.: uluru.1728 Posted: Thu Jun 4 19:17:06 1987 Date-Received: Sat, 6-Jun-87 11:34:22 EDT Reply-To: calder@uluru.UUCP (Paul Calder) Distribution: world Organization: Stanford University (Centre for Integrated Systems) Lines: 48 Keywords: Version 1.2, member functions I have had a few problems with pointers to member functions in version 1.2 of the C++ translator. Specifically, there seem to be bugs in using local variables of type "pointer-to-member-function", especially if the class concerned has virtual member functions. Here is a simple example. struct S { virtual void f() { } } s; void (S::*p)() = &S::f; // works fine if p is global int main() { (s.*p)(); } But now try making p local to main. struct S { virtual void f() { } } s; int main() { void (S::*p)() = &S::f; // "syntax error" if p is local (s.*p)(); } OK then, why not make a global typedef and a local variable? struct S { virtual void f() { } } s; typedef void (S::*pf)(); int main() { pf p = &S::f; (s.*p)(); } // "bus error (or something nasty...)" Note that if S::f is not virtual, all is well. (Also note that this used to work fine under version 1.1) Is this a bug, or am I missing something? Paul Calder (calder@uluru.stanford.edu) Stanford University, Centre for Integrated Systems, Computer Systems Lab.