Path: utzoo!censor!geac!torsqnt!hybrid!scifi!bywater!uunet!tdatirv!sarima From: sarima@tdatirv.UUCP (Stanley Friesen) Newsgroups: comp.lang.c++ Subject: Re: Calling virtuals from destructors Message-ID: <84@tdatirv.UUCP> Date: 15 Jan 91 15:48:41 GMT References: <424@nec-gw.nec.com> Reply-To: sarima@tdatirv.UUCP (Stanley Friesen) Distribution: na Organization: Teradata Corp., Irvine Lines: 32 In article <424@nec-gw.nec.com> stuart@NECAM.tdd.sj.nec.com (Stuart Palmer) writes: > >If you call a virtual member function from a destructor, what is >the behavior? >In Sun 2.0, if you call a virtual member function from >a destructor, the "actual" virtual function that is compiled into >the class vtbl will not get called. Rather, the virtual function >at the class level where the call was made gets called. This is correct, at least for version 2.XC++. This is so because by the time a destructor is called all derived classes have been destroyed, so the object is no longer a derived class object. Thus the destuctor can make a 'static' call to the function. >This is different than Glockenspiel 1.2. 1.2 calls the virtual >function from the vtbl (as might be expected?). This is (or would be) wrong for a 2.X compiler, but it may be that as a 1.2 compiler this was correct at the time. (I.e. this could be something that changed between version 1.2 and 2.0 of cfront). >Is this a bug in one of the compilers? It is either a bug or an archaism in the Glockenspiel compiler. By the way, this should probably be in the FAQ, it has been asked enough. -- --------------- uunet!tdatirv!sarima (Stanley Friesen)