------- Comment #3 from i dot am dot inuyasha at gmail dot com 2010-08-25 12:10 ------- So, how do we report bugs in the C standard? &x should give the byte address of x regardless how many bits it is, and sizeof(x) should give the size rounded up to the nearest byte.
All the pages I could find summarize this as "you don't need the address." I've found at least two scenarios that do: 1) Aid in debugging by displaying the address so that you can more easily find it in a memory dump. 2) Sending only as many bytes as necessary over a network. In the second case you put less-used fields toward the end of the struct and pack it as tight as possible to reduce bandwidth usage. You check which fields are not set to their default values, take the offset of the last such field, and transmit only that many bytes of the struct. The server fills in all default values, and then copies the received data overtop to fill in the transmitted values. Not being able to find the address (and thus the offset) of a bitfield member means you need to either waste bytes using an entire uint8_t for one bit, add a dummy byte after any group of bitfields, or not use bitfields at all (using shifting and masking instead). A wasted byte or two may seem insignificant but over millions of packets they can definitely add up. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36483