Boost logo

Boost Testing :

From: Bronek Kozicki (brok_at_[hidden])
Date: 2005-10-20 02:24:42


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

B.


Boost-testing list run by mbergal at meta-comm.com