This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/31176] reorder class data members to minimize space waste
- From: "fang at csl dot cornell dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 14 Mar 2007 18:14:52 -0000
- Subject: [Bug c++/31176] reorder class data members to minimize space waste
- References: <bug-31176-1186@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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