Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!ut-sally!utah-cs!donn From: donn@utah-cs.UUCP (Donn Seeley) Newsgroups: comp.lang.c++ Subject: some bugs with pointers to member functions in C++ 1.2.1 Message-ID: <4533@utah-cs.UUCP> Date: Tue, 28-Apr-87 23:42:16 EDT Article-I.D.: utah-cs.4533 Posted: Tue Apr 28 23:42:16 1987 Date-Received: Thu, 30-Apr-87 04:33:13 EDT Organization: University of Utah CS Dept Lines: 42 Try feeding the following fragment to C++ 1.2.1: struct foo; typedef void (foo::*PMF_foo)(); struct foo { PMF_foo pmf; virtual void f() { (this->*pmf)(); } }; On our system, the translator finds no syntax errors but eventually prints 'internal <> error: bus error (or something nasty like that)'. If you remove the typedef and declare the member 'pmf' without one, as void (foo::*pmf)(); the translator is happy and the code looks right (I haven't tested it). Removing the 'virtual' specifier in the definition of f() also makes the translator feel better. I noticed another peculiarity while playing with this bug -- it's impossible to declare a function argument as a pointer to member functions without using a typedef. The translator simply chokes on the syntax. The following fails: struct foo; void f( void (foo::*)() ); but a variant using a typedef will work: struct foo; typedef void (foo::*PMF_foo)(); void f( PMF_foo ); I hope I got the syntax right, Donn Seeley University of Utah CS Dept donn@cs.utah.edu 40 46' 6"N 111 50' 34"W (801) 581-5668 utah-cs!donn