Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!ut-sally!im4u!rutgers!labrea!decwrl!pyramid!voder!apple!joemac From: joemac@apple.UUCP (Joe MacDougald) Newsgroups: comp.lang.c++ Subject: cfront/c++ problem Message-ID: <6191@apple.UUCP> Date: Wed, 9-Sep-87 21:13:25 EDT Article-I.D.: apple.6191 Posted: Wed Sep 9 21:13:25 1987 Date-Received: Sat, 12-Sep-87 03:04:43 EDT Organization: Apple Computer, Inc., Cupertino, USA Lines: 39 Keywords: pointer to virtual method cfront dies with an bus error when compiling the following: struct T { int f; T() { f = 1; } // constructor virtual int getf(); }; int T::getf() { return f; } typedef int (T::*PROC)(); // S 5.4.5 p. 154 : pointer to member function // of T taking no args, returning int. main() { T t; // t is an instance of T PROC p = &T::getf; // p points to T's member function getf /*ERROR*/ int r = (t.*p)(); // call function pointed at by p, assign to r } The error occurs at the point of invocation of the function pointed to by p. If the member function is not declared virtual there are no problems in compilation or execution. Nowhere does Stroustrup mention pointers to virtual methods, so I wonder if it is a valid operation. If it is invalid, cfront needs to exit more gracefully. Has anyone used this aspect of the language? Any comments would be greatly appreciated. Thanks, Joe