Actions
| Post | |
| Subscribe | |
| Unsubscribe |
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [cxx-abi-dev] ::delete and deleting destructors
- To: cxx-abi-dev@xxxxxxxxxxxxxxxx
- Subject: Re: [cxx-abi-dev] ::delete and deleting destructors
- From: Dennis Handly <dhandly@xxxxxxxxxx>
- Date: Wed, 5 Sep 2007 21:27:56 -0700 (PDT)
>From: Jason Merrill <jason@xxxxxxxxxx> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15097 >seems to indicate a problem with the ABI. The standard requires that >::delete use the global operator delete, but properly deleting an object >of a type with a virtual destructor requires that use the deleting >destructor, which will call the operator delete declared in the class, >if any. We would have to skip the class one and only use it for the "delete p" case. >g++ gets this wrong by always calling the global operator delete, which >means freeing the wrong pointer in the presence of multiple inheritance. aC++ also gets it wrong. 400025d0: ::op new(16) 40002630: ::op new(24) <<<< 40002638: ctor base 40002640: ctor base2 40002630: ctor derived 40002630: dtor derived 40002640: dtor base2 40002638: dtor base 40002638: ::op delete <<<< >It seems to me that fixing this would require a change to the ABI, Jason With Mark's suggestion, do we need to add that as an engineering note?? >From: Mark Mitchell <mark@xxxxxxxxxxxxxxxx> >Why can't the code generated by the compiler for "::delete x", where "x" >is of type "X", a dynamic class, be: > // This is a virtual call, so calls the destructor for most-derived type. > x->X::~X(); By definition X::~X() isn't a virtual call but we need one?? It seems you can't write it in C++, without compiler help to access the function pointer in the vtable. (But this is a moot point since this doesn't change.) > // Call the global deallocation function > ::operator delete(p); Mark Mitchell That should do it. And we have to do it in your order since vtbl pointer gets changed by ~X.
- Follow-Ups:
- Re: [cxx-abi-dev] ::delete and deleting destructors
- From: Jason Merrill
- Re: [cxx-abi-dev] ::delete and deleting destructors
- Prev by Date: Re: [cxx-abi-dev] ::delete and deleting destructors
- Next by Date: Re: [cxx-abi-dev] ::delete and deleting destructors
- Previous by thread: Re: [cxx-abi-dev] ::delete and deleting destructors
- Next by thread: Re: [cxx-abi-dev] ::delete and deleting destructors
- Index(es):