🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

1.35.1- inheritance bug?

#277
From: Glen Ditchfield
Date: Mon, 10 Jul 1989 18:05
42 lines
2245 bytes
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_
Technical Details
Message-ID: <27600@watmath.waterloo.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!watmath!watmsg!gjditchfield

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wasatch!cs.utexas.edu!uunet!watmath!watmsg!gjditchfield
From: gjditchfield@watmsg.waterloo.edu (Glen Ditchfield)
Newsgroups: gnu.g++.bug
Subject: 1.35.1- inheritance bug?
Message-ID: <27600@watmath.waterloo.edu>
Date: 10 Jul 89 18:05:32 GMT
Sender: daemon@watmath.waterloo.edu
Lines: 42