Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!asuvax!ncar!mephisto!mcnc!thorin!jason.cs.unc.edu!tuck From: tuck@jason.cs.unc.edu (Russ Tuck) Newsgroups: comp.lang.c++ Subject: virt base c'tor -- my error or CC bug? Keywords: CC, cfront, 2.0, multiple inheritance, virtual base class Message-ID: <11582@thorin.cs.unc.edu> Date: 22 Jan 90 17:41:10 GMT 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: 38 I think I've found a bug in the AT&T C++ 2.0 compiler, cfront, but I'm willing to be shown the error in my code. On p. 82, section 12.6.2, of the C++ (2.0) Reference Manual (AT&T select code 307-146), it says: "All sub-objects for virtual base classes are initialized by the constructor of the most derived class. If a constructor of the most derived class does not specify a mem-initializer for a virtual base class then that virtual base class must have a default constructor or no constructors." The example in the manual following the quote above shows the case of no mem-initializer in the most derived class's constructor, where the virtual base class has a default constructor. I would like to use the other case described in the quote: a mem-initializer in the most derived class's constructor and no default initializer in the virtual base class. 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: CC t.c: "t.c", line 3: error: virtual base V has no default initializer "t.c", line 5: error: unexpected argument list: no base class V 2 errors Is there something wrong with this code, or is this indeed a compiler bug? 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