|
Boost Testing : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-10-21 08:54:15
Bronek Kozicki <brok_at_[hidden]> writes:
> Jim Douglas wrote:
>> main() {
>>
>> A *MyPtr;
>> MyPtr = new B; // this is perfectly legal and very useful
>> ...
>> delete MyPtr; // only calls the dtor for A
>> }
>>
>> In the above example the delete would only clean up the base class A and
>> leave bits of the derived class B lying around in memory causing a
>
> this is actually undefined behaviour, and "pieces of former B
> object" might be corrupting heap state or the whole thing could just
> blow up
Unless B has a trivial destructor, of course.
-- Dave Abrahams Boost Consulting www.boost-consulting.com