Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uunet!brunix!sdm From: sdm@cs.brown.edu (Scott Meyers) Newsgroups: comp.lang.c++ Subject: cfront 2.0 bug in base class initialization Message-ID: <25617@brunix.UUCP> Date: 16 Jan 90 14:24:21 GMT Sender: news@brunix.UUCP Reply-To: sdm@cs.brown.edu (Scott Meyers) Organization: Brown University Department of Computer Science Lines: 33 The following program demonstrates what is almost certainly a bug in cfront 2.0. The base class has two constructors, only the first of which is needed. But if the second constructor is missing, then the first one is never called and the base part of the derived object doesn't get initialized. #include class Base { public: Base(class Derived &p) { cout << "Base::Base -- 1\n"; } Base(Base &g) { cout << "Base::Base -- 2\n"; } // This second constructor is never called, but if it's not here, // then the first constructor won't be called and the Base part of // a Derived object will be uninitialized. }; class Derived: public Base { public: Derived(): Base(*this) { cout << "Derived::Derived\n"; } }; main() { Derived *pd = new Derived; } g++ properly handles initialization without the superfluous constructor. If I'm mistaken, I'd appreciate it if somebody would set me straight. Scott