keffer@SPERM.OCEAN.WASHINGTON.EDU (Tom Keffer) (01/07/90)
In the following, IntMatrix and DoubleMatrix have >private< base classes --- they should not be usable for type conversions. But, g++ attempts to use them. This compiles without protest on the AT&T Version 2 compiler, but issues an error about a conversion operator being needed with g++. code: ====================================== class IntVec { public: IntVec(); friend operator+(const IntVec&, const IntVec&); }; class DoubleVec { public: DoubleVec(); DoubleVec(const IntVec&); friend operator+(const DoubleVec&, const DoubleVec&); }; class IntMatrix : private IntVec { public: IntMatrix(); friend operator+(const IntMatrix&, const IntMatrix&); }; class DoubleMatrix : private DoubleVec { public: DoubleMatrix(); DoubleMatrix(const IntMatrix&); friend operator+(const DoubleMatrix&, const DoubleMatrix&); }; main() { IntMatrix im; DoubleMatrix dm; im + dm; // Should convert "im" to a DoubleMatrix, // but sees the + operator in the base class. } sperm[tmp]% g++ -v -c junk.cc gcc version 1.36.1 (based on GCC 1.36) /usr/local/lib/gcc-cpp -+ -v -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__HAVE_68881__ -Dmc68020 junk.cc /usr/tmp/cca21089.cpp GNU CPP version 1.36 /usr/local/lib/gcc-cc1plus /usr/tmp/cca21089.cpp -quiet -dumpbase junk.cc -version -o /usr/tmp/cca21089.s GNU C++ version 1.36.1 (based on GCC 1.36) (68k, MIT syntax) compiled by GNU C version 1.36. default target switches: -m68020 -mc68020 -m68881 -mbitfield junk.cc: In function int main (): junk.cc:31: type conversion required for types `IntMatrix' and `DoubleMatrix'