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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
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.

Reply via email to