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

2008-08-13 Thread gcc-bugzilla at contacts dot eelis dot net
--- Comment #9 from gcc-bugzilla at contacts dot eelis dot net 2008-08-13 22:24 --- Ok, I see. Sorry for wasting your time. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37119

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

2008-08-13 Thread rguenth at gcc dot gnu dot org
--- Comment #8 from rguenth at gcc dot gnu dot org 2008-08-13 22:20 --- The relevant ABI says "a bit-field mut entirely reside in a storage unit appropriate for its declared type" which means it all makes very much sense. -- rguenth at gcc dot gnu dot org changed: Wha

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

2008-08-13 Thread pinskia at gcc dot gnu dot org
--- Comment #7 from pinskia at gcc dot gnu dot org 2008-08-13 22:16 --- >brings it down to 5 bytes (we seem to never pack chars with other types) We do, but we don't packed if it overflows into the next unit. -- pinskia at gcc dot gnu dot org changed: What|Remov

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

2008-08-13 Thread rguenth at gcc dot gnu dot org
--- Comment #6 from rguenth at gcc dot gnu dot org 2008-08-13 22:05 --- struct X { uint32_t a:17; uint8_t b:8; uint8_t c:1; } __attribute__((packed)); brings it down to 5 bytes (we seem to never pack chars with other types) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37119

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

2008-08-13 Thread rguenth at gcc dot gnu dot org
--- Comment #5 from rguenth at gcc dot gnu dot org 2008-08-13 22:01 --- This is also 4 bytes in size: struct X { uint32_t a:17; uint16_t b:8; uint16_t c:1; }; -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37119

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

2008-08-13 Thread rguenth at gcc dot gnu dot org
--- 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_

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

2008-08-13 Thread pinskia at gcc dot gnu dot org
--- Comment #3 from pinskia at gcc dot gnu dot org 2008-08-13 21:43 --- >I don't follow. 4 bytes is 4*8=32 bits, which is more than 26, no? Or the ABI says the different types are not merged together. Really you have to look into what the ABI says to figure out the correct answer. I d

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

2008-08-13 Thread gcc-bugzilla at contacts dot eelis dot net
--- Comment #2 from gcc-bugzilla at contacts dot eelis dot net 2008-08-13 21:39 --- (In reply to comment #1) > so 26bits which is a little over 4 bytes. I don't follow. 4 bytes is 4*8=32 bits, which is more than 26, no? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37119

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

2008-08-13 Thread pinskia at gcc dot gnu dot org
--- Comment #1 from pinskia at gcc dot gnu dot org 2008-08-13 21:26 --- > struct X { uint32_t a:17; uint8_t b:8; bool c:1; }; 0...16 is a as uint32_t is more than 17 bytes 17...24 is b as uint8_t is 8 bytes 25...26 is c as bool is 1 byte so 26bits which is a little over 4 bytes. so it