[Bug c++/37119] sizeof simple struct consisting of bit-fields too large and unpredictable

rguenth at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Aug 13 22:01:00 GMT 2008



------- Comment #4 from rguenth at gcc dot gnu dot org  2008-08-13 21:59 -------
Seems like we do that since forever, so we cannot change this anyway.  But
surely it looks unintuitive that

struct X { uint32_t a:17; uint16_t b:8; uint8_t c:1; };

is 4 bytes while

struct X { uint32_t a:17; uint8_t b:8; uint8_t c:1; };

is 8 bytes in size.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org, matz at gcc dot gnu dot
                   |                            |org
   GCC host triplet|                            |x86_64-pc-linux
 GCC target triplet|x86_64-pc-linux-gnu         |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37119



More information about the Gcc-bugs mailing list