This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/31176] reorder class data members to minimize space waste



------- Comment #1 from fang at csl dot cornell dot edu  2007-03-14 18:14 -------
Interesting.  Do the attributes apply to derived classes automatically?  

struct B __attribute__((reorder)) {
char a;
int b;
};

struct D : public B {
char c, d, e;
};

Is D also allowed to reorder members a and b? even with an explicit
__attribute__((reorder))?
Would this break static_cast-ing from D to B due to change in layout?

D d;
int x = static_cast<const B&>(d).b; // how does this work if D's layout is not
a mere extension?

This might warrant a diagnostic saying this might not do what is expected. 
(What DOES one expect?)

Fang


-- 

fang at csl dot cornell dot edu changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |fang at csl dot cornell dot
                   |                            |edu


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]