------- Additional Comments From dberlin at gcc dot gnu dot org  2005-05-10 
16:07 -------
Subject: Re:  [4.1 Regression] wrong code with
        downcast in C++

On Tue, 2005-05-10 at 16:01 +0000, giovannibajo at libero dot it wrote:
> ------- Additional Comments From giovannibajo at libero dot it  2005-05-10 
> 16:01 -------
> In fact, the salias dump for the C++ testcase says:
> 
> ---------------------------------------------------------------
> ;; Function void bar() (_Z3barv)
> 
> structure field tag SFT.2 created for var sb offset 0 size 32
> void bar() ()
> {
>   struct B sb;
> 
> <bb 0>:
>   foo (&sb.D.1580);
>   return;
> 
> }
> ---------------------------------------------------------------
> 
> so it looks like the substructure *is* at offset zero.
> 
> 

The only case we get anything wrong is when you can get back at the
*CONTAINING* structure's members legally (which in C++ means the derived
class) when they aren't in a place they will be clobbered anyway.


IE if you can take a pointer to somewhere in the middle of a structure,
subtract some bytes, and get back the containing structure, which is
effectively what dynamic cast is doing :)




-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21407

Reply via email to