home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!hal.com!hal!brennan
- From: brennan@hal.com (Dave Brennan)
- Newsgroups: comp.lang.c++
- Subject: cfront, objectcenter bug?
- Message-ID: <BRENNAN.92Sep3003646@yosemite.hal.com>
- Date: 3 Sep 92 06:36:46 GMT
- Organization: HaL Computer Systems, Austin, TX
- Lines: 50
- NNTP-Posting-Host: yosemite.hal.com
-
- When the following program is run, both cfront and objectcenter print:
-
- destruct derived
- destruct base
- destruct base
- delete base
-
- g++ won't compile this program. I believe that the explicit call to
- base::~base should not result in the derived destructor being called.
- Can anyone confirm or deny this?
-
-
- extern "C" void puts (char *);
-
- class base
- {
- public:
- virtual ~base ()
- { puts ("destruct base"); }
- void operator delete (void *)
- { puts ("delete base"); }
- void destruct ()
- { base::~base (); }
- };
-
- class derived : public base
- {
- public:
- ~derived ()
- { puts ("destruct derived"); }
- void operator delete (void *)
- { puts ("delete derived"); }
- };
-
- int
- main ()
- {
- base *b = new derived;
-
- // This call to destruct wipes out the vtbl!
- b->destruct ();
-
- delete b;
- }
-
- --
- Dave Brennan HaL Computer Systems
- brennan@hal.com (512) 794-2855
-
- Visit the Emacs Lisp Archive: archive.cis.ohio-state.edu:pub/gnu/emacs
-