This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/51568] Enum value is not extracted properly via a union
- From: "rearnsha at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 15 Dec 2011 17:17:34 +0000
- Subject: [Bug c/51568] Enum value is not extracted properly via a union
- Auto-submitted: auto-generated
- References: <bug-51568-4@http.gcc.gnu.org/bugzilla/>
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));