gjditchfield@watmsg.waterloo.edu (Glen Ditchfield) (07/11/89)
g++ misses one error in this code, and generates an error message that I don't understand for something that isn't a problem as far as I know. ------------------------------------------------------------------------------- class Base1 { }; class Base2 { protected: void memf(Base1*); }; class Derv1:Base1 { }; class Derv2:Base2 { public: Derv2(Derv1& l) { Base2::memf( &l); }; void memf(Derv1& l) { Base2::memf( (Base1*)&l); }; }; ------------------------------------------------------------------------------- When g++ sees the body of Derv2::Derv2, it should complain that there is no Base2::memf() function that takes a Derv1* as an argument. It should have no problems with the body of Derv2::memf. Instead I get these messages: ------------------------------------------------------------------------------- cd /u/gjditchfield/C++/Lists/ g++ -v -c bug.cc g++ version 1.35.1- /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -D__cplusplus -Dvax -Dunix -D__vax__ -D__unix__ bug.cc /tmp/cc017889.cpp GNU CPP version 1.35.94 /usr/local/lib/gcc-cc1plus /tmp/cc017889.cpp -quiet -dumpbase bug.cc -noreg -version -o /tmp/cc017889.s GNU C++ version 1.35.1- (vax) compiled by GNU C version 1.35. In method void Derv2::memf (struct Derv1 &): bug.cc:13: type `Derv1' is derived from private `Base1' In method struct Derv2 *Derv2::Derv2 (struct Derv1 &): bug.cc:12: type `Derv1' is derived from private `Base1' Compilation finished at Mon Jul 10 14:00:32 ------------------------------------------------------------------------------- I can't tell what g++ thinks is wrong with lines 12 and 13. Glen Ditchfield gjditchfield@violet.uwaterloo.ca Office: DC 2517 Dept. of Computer Science, U of Waterloo, Waterloo, Ontario, Canada, N2L 3G1 "... and the rest, we will spend foolishly!" -- _Svengali_