Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • See my comments above Commented Jul 29, 2022 at 8:54
  • @Frankie_C I'm not 100% convinced that GCC is non-compliant in the example in the Godbolt link. The excerpt from the Standard I quoted (which is essentially unchanged in C17) suggests that the compiler can legally allocate a uint32_t for a bit-filed with a specified type of uint8_t. Can you provide a quote from the Standard that states that the fourth member (in OP's first snippet) must be in a separate storage unit? Commented Jul 29, 2022 at 9:07
  • 1
    Seems you're right, it isn't so evident anyway: While the standard specifically allows only _Bool, signed int, and unsigned int as bit-field types, then adds at the end or some other implementation-defined type (6.7.2.1 Structure and union specifiers). While for the first three, with some hesitation, comes obvious that the single bitfields can be packed in the same storage, this doesn't sound so 'natural' when the types are different. I'll fix my comments above. Commented Jul 29, 2022 at 10:03