Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!usc!apple!ames!ncar!mephisto!mcnc!thorin!jason!tuck From: tuck@jason.cs.unc.edu (Russ Tuck) Newsgroups: comp.lang.c++ Subject: Re: virt base c'tor -- my error or CC bug? Keywords: CC, cfront, 2.0, multiple inheritance, virtual base class Message-ID: <11594@thorin.cs.unc.edu> Date: 23 Jan 90 00:36:52 GMT References: <11582@thorin.cs.unc.edu> Sender: news@thorin.cs.unc.edu Reply-To: tuck@jason.cs.unc.edu (Russ Tuck) Distribution: na Organization: University Of North Carolina, Chapel Hill Lines: 37 In article <11582@thorin.cs.unc.edu> tuck@jason.cs.unc.edu (Russ Tuck) writes: >I think I've found a bug ... >Here's a trivial example program showing this case. > > class V { public: V(int); }; > > class A : public virtual V { public: A(); }; > > A::A() : V(1) {} > > V v(1); > A a; > >CC (cfront 2.0, running on any of Sun4, DEC 3100, VAX 785) gives these >error messages when compiling the above code ..... I've found what appears to be a good work-around to this problem: adding a private default constructor to class V. This gets rid of the error messages, but should not change V's public or protected interfaces because the added c'tor is private. Here's the revised code. class V { private: V(); public: V(int); }; class A : public virtual V { public: A(); }; A::A() : V(1) {} V v(1); A a; CC (cfront 2.0) compiles this without giving errors or warnings. (Of course, it won't link without defining V's methods.) Russ Tuck tuck@cs.unc.edu UNC Dept. of Computer Science ...!mcnc!unc!tuck CB 3175, Sitterson Hall Chapel Hill, NC 27599-3175, USA (919) 962-1755 or 962-1700