This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/21407] [4.1 Regression] wrong code with downcast in C++
- From: "dberlin at dberlin dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 10 May 2005 16:07:30 -0000
- Subject: [Bug tree-optimization/21407] [4.1 Regression] wrong code with downcast in C++
- References: <20050506002331.21407.pinskia@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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