[Bug c++/31176] reorder class data members to minimize space waste
fang at csl dot cornell dot edu
gcc-bugzilla@gcc.gnu.org
Wed Mar 14 18:15:00 GMT 2007
------- 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
More information about the Gcc-bugs
mailing list