[Bug c/51568] Enum value is not extracted properly via a union
rearnsha at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Dec 15 17:28:00 GMT 2011
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51568
Richard Earnshaw <rearnsha at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Richard Earnshaw <rearnsha at gcc dot gnu.org> 2011-12-15 17:17:34 UTC ---
On linux sizeof (struct rec) is 7, so how do you expect an unsigned (size = 4)
to hold the entire value?
If you want a packed enum, you need to specify the packed on the element
declaration, not just on the overall structure:
struct rec {
unsigned short w;
unsigned char c;
enum en e __attribute__((packed));
} __attribute__((packed));
More information about the Gcc-bugs
mailing list