public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* type layout bug, or not?
@ 2006-02-21 21:45 Chris Lattner
  2006-02-21 21:51 ` Andrew Pinski
  0 siblings, 1 reply; 3+ messages in thread
From: Chris Lattner @ 2006-02-21 21:45 UTC (permalink / raw)
  To: GCC Development

Consider this C++ example (I've annotated each class decl with the  
unit size of each structure):

struct A { virtual ~A(); };     // 4
struct B { virtual ~B(); };     // 4

struct X : virtual public A,
                 virtual public B {  // 8
};

struct Y : virtual public B { // 4
   virtual ~Y();
};

struct Z : virtual public X, public Y {   // 8
   Z();
};

Z::Z() {}


In this example, the DECL_SIZE_UNIT of "Z" is 8 bytes.  Here, the  
FIELD_DECL corresponding to it's Y superclass has an offset of 0  
bytes and size 4 bytes.

Confusingly (to me at least), the FIELD_DECL for the X superclass has  
an offset of 4 bytes and and a size of 8 bytes, which means that the  
end of the object is 12 bytes, despite the fact that Z has a  
DECL_SIZE_UNIT of 8 bytes.

Is this the intended layout of this structure?  What does it mean  
when a field runs off the end of the structure?  In this case, should  
I just ignore the type size and assume that the 8 bytes are  
dynamically there?

Thanks,

-Chris

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: type layout bug, or not?
  2006-02-21 21:45 type layout bug, or not? Chris Lattner
@ 2006-02-21 21:51 ` Andrew Pinski
  2006-02-22 10:47   ` Richard Guenther
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Pinski @ 2006-02-21 21:51 UTC (permalink / raw)
  To: Chris Lattner; +Cc: GCC Development


On Feb 21, 2006, at 4:44 PM, Chris Lattner wrote:
>
> Is this the intended layout of this structure?  What does it mean when 
> a field runs off the end of the structure?  In this case, should I 
> just ignore the type size and assume that the 8 bytes are dynamically 
> there?

I wonder if this is the same problem as recorded as PR 22488.  To me it 
does sound
like the same issue.

Thanks,
Andrew Pinski

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: type layout bug, or not?
  2006-02-21 21:51 ` Andrew Pinski
@ 2006-02-22 10:47   ` Richard Guenther
  0 siblings, 0 replies; 3+ messages in thread
From: Richard Guenther @ 2006-02-22 10:47 UTC (permalink / raw)
  To: Andrew Pinski; +Cc: Chris Lattner, GCC Development

On 2/21/06, Andrew Pinski <pinskia@physics.uc.edu> wrote:
>
> On Feb 21, 2006, at 4:44 PM, Chris Lattner wrote:
> >
> > Is this the intended layout of this structure?  What does it mean when
> > a field runs off the end of the structure?  In this case, should I
> > just ignore the type size and assume that the 8 bytes are dynamically
> > there?
>
> I wonder if this is the same problem as recorded as PR 22488.  To me it
> does sound
> like the same issue.

Which should remind the C++ folks that they promised to fix this for 4.2 :P

Richard.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-02-22 10:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-02-21 21:45 type layout bug, or not? Chris Lattner
2006-02-21 21:51 ` Andrew Pinski
2006-02-22 10:47   ` Richard Guenther

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).