This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Bug in abstract methods in destructors


On Nov  4, 1999, Benjamin Forgeau <forgeau@tu-harburg.de> wrote:

> 	I´m using a lot of abstract methods, and it seems that egcs interprets
> such methods as elsewhere implemented when they are called from the
> destructor.

gcc's behavior is compliant with the ISO C++ Standard.  When you get
to A's destructor, the B sub-object has already been destructed, so it
doesn't make sense to run B::abstract_method.  So, when you get to the
A destructor, the dynamic type of the object has already ``decay''ed
from B to A, and the final overrider of abstract_method is
A::abstract_method.  Even though it is not defined in this translation
unit, it would still be possible to define it elsewhere, and, since
you (unintentionally) refer to it, gcc emits an invocation of it, that
causes the ``undefined reference'' link error.

-- 
Alexandre Oliva http://www.ic.unicamp.br/~oliva IC-Unicamp, Bra[sz]il
oliva@{lsd.ic.unicamp.br,guarana.{org,com}} aoliva@{acm,computer}.org
oliva@{gnu.org,kaffe.org,{egcs,sourceware}.cygnus.com,samba.org}
** I may forward mail about projects to mailing lists; please use them


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]