c++language-lawyerbit-fieldsimplementation-defined-behavior

Characteristics of bit-Fields in C++


Reading https://en.cppreference.com/w/cpp/language/bit_field, are the following conclusions correct?

(for C see: Characteristics of bit-Fields in C)


Solution

  • "The question has three very clear points towards one specific feature in one language. So it would be helpful to get one answer comprising all three points of the question"

    Addressing points one-by-one

    In short, the conclusion is that no guarantees exist that bit-field implementation between various new specifications of C++ will be consistent. Portability is therefore difficult, if not impossible from one C++ implementation to the other, forcing that the specifications and other documentation supporting the C++ compiler being used must be consulted for any application using it to be sure of its implementation (rules) regarding how padding, or other attributes of bit-fields are implemented.