Path: utzoo!attcan!uunet!lll-winken!lll-tis!ati.tis.llnl.gov!tjt From: tjt@ati.tis.llnl.gov (Tim Tessin) Newsgroups: comp.lang.c++ Subject: Bug in cfront (1.2.1) using virtual destructors Message-ID: <22271@tis.llnl.gov> Date: 14 Jun 88 23:16:49 GMT Sender: news@tis.llnl.gov Reply-To: tjt@ati.tis.llnl.gov (Tim Tessin) Organization: Lawrence Livermore National Laboratory, Livermore CA Lines: 43 There seems to be a bug in cfront (1.2.1) (on a Sun 3). Can anyone confirm or deny or provide a better workaround? Example follows: class A { public: A(); virtual ~A(); }; class B : public A { public: B (); ~B (); }; class C : public A { public: C(); ~C(); B b; //int a; }; C::C() {} C::~C() {} Note that A's destructor is virtual, making all descendant dtors (B,C) also virtual. Cfront gives me the "nasty bus error" message on the definition of ~C (last line). The problems appears to be the member B::b in class C. Class C may have members which don't have virtual dtors and compiles fine (e.g. if you have the commented out line above). The only work around I can find, is to define the destructor bodies in a separate file and compile with a modified version of the A class declaration which has the virtual specifier removed. Fortunatly, the separately compiled dtor is compatible with the "virtual" version of the dtor. Tim Tessin - Lawrence Livermore National Laboratory PHONE: (415) 423-4560 ARPA: tjt@tis.llnl.gov UUCP: {ames,ihnp4,lll-crg,lll-lcc,mordor}!lll-tis!tjt