rfrench@ATHENA.MIT.EDU ("Robert S. French") (02/25/89)
There is an odd bug in G++ 1.33 which occurs when a pointer to a subclass member is passed to a function of the superclass by reference. In other words: class foo { int x; public: broken(foo*&); }; class bar : foo { int y; }; working(foo*&) { } baz() { foo *inst = new foo; foo a1; bar b1; working(&a1); working(&b1); inst->broken(&a1); inst->broken(&b1); // This line will fail } The first three calls in baz() will succeed. The second fails. Here are the diagnostics: g++ version 1.33.0 /mit/gnu/vaxlib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dvax -Dunix -D__vax__ -D__unix__ foo.c /tmp/cc008347.cpp GNU CPP version 1.33 /mit/gnu/vaxlib/gcc-c++ /tmp/cc008347.cpp -quiet -dumpbase foo.c -version -o /tmp/cc008347.s GNU C++ version 1.33.0 (vax) compiled by GNU C version 1.33. In function baz (): foo.c:24: bad argument 0 for function `foo::broken (struct foo *&)' (type was struct foo *) The program works fine if broken is defined as broken(foo*) or broken(foo&) and baz() is changed accordingly. The bug only shows itself when pointers are passed by reference. (Some code in InterViews 2.4 tickled this bug) Rob French