schmidt%crimee.ics.uci.edu@PARIS.ICS.UCI.EDU ("Douglas C. Schmidt") (01/03/89)
Hi, The following cryptic looking C++ code comes from page 309 of Stroustrup and Lippman's ``Pointers to Class Members in C++'' article from the USENIX C++ Conference, 1988. It fails to compile on g++ 1.32. Here's the code: ---------------------------------------- class X { public: int i; void foo ( int ) { } }; main ( int, char *argv [ ] ) { void (X::*pmfXVi2)(int) = &X::foo; } ---------------------------------------- Here are the diagnostics: ---------------------------------------- In function main (int, char **): bug.c:10: parse error before `*' ---------------------------------------- Note that if the declaration is moved to the outer scope ( i.e., outside of main() ) the compiler handles this correctly ( there seems to be a general problem correctly parsing with this type of declaration in both g++ and cfront 1.2.1. ). Doug
mdt%yahi.stanford.edu@PARIS.ICS.UCI.EDU (Michael Tiemann) (01/17/89)
class X { public: int i; void foo ( int ) { } }; main ( int, char *argv [ ] ) { void (X::*pmfXVi2)(int) = &X::foo; } GNU C++ cannot handle void (*pf)(int); and it cannot handle void (X::*pmf)(int); for the same reason. It can handle auto void (X::*pmf)(int); Michael