https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70620

--- Comment #3 from Zhendong Su <su at cs dot ucdavis.edu> ---
(In reply to Jonathan Wakely from comment #2)
> Your code is equivalent to:
> 
>   delete reinterpret_cast<D *>(static_cast<B1 *>(new E));
> 
> which means the conversion is not done safely, and you get a D* that doesn't
> point to the D subobject.
> 
> Compare:
> 
>   E* e = new E;
>   std::cout << (D*)e << '\n' << (B1*)e << '\n' << (D*)(B1*)e << '\n';
> 
> The expression (D*)(B1*)e is not the same as (D*)e, i.e. it does not produce
> the address of the D subobject.

Thanks Jonathan. That's what I had thought, but the change in behavior caused
me to wonder.

Reply via email to