This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/25274] sizeof(struct) fails for 'unlucky' structure
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 6 Dec 2005 13:08:07 -0000
- Subject: [Bug c/25274] sizeof(struct) fails for 'unlucky' structure
- References: <bug-25274-11823@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #1 from rguenth at gcc dot gnu dot org 2005-12-06 13:08 -------
The C standard allows for arbitrary padding in between elements, so this
behavior is expected. Use __attribute__((packed)) on the type to get a struct
without padding if you need that for whatever reason (it will be slower to
access unaligned fields). You can also sort the fields starting with elements
with
the largest size to minimize required padding.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25274