🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #2132

Visibility of base class

#2132
From: Tom Keffer
Date: Sat, 06 Jan 1990 18:51
52 lines
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'
Technical Details
Message-ID: <9001061851.AA21092@sperm.ocean.washington.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!SPERM.OCEAN.WASHINGTON.EDU!keffer

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!SPERM.OCEAN.WASHINGTON.EDU!keffer
From: keffer@SPERM.OCEAN.WASHINGTON.EDU (Tom Keffer)
Newsgroups: gnu.g++.bug
Subject: Visibility of base class
Message-ID: <9001061851.AA21092@sperm.ocean.washington.edu>
Date: 6 Jan 90 18:51:14 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 52