Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Tom Keffer
Sat, 06 Jan 1990 18:51
Visibility of base class
Author: Tom Keffer
Date: Sat, 06 Jan 1990 18:51
Date: Sat, 06 Jan 1990 18:51
52 lines
2142 bytes
2142 bytes
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'
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads