Bit fields allow the developers to declare a class member with a specific size.
However, the size of a bit field is also constrained by its type: even if the specified size is greater than the size of the type, the value of the
bit field will not exceed the maximum value of this type. The extra bits will just create unused padding.
The incompatibility of the size of the type with the specified size can have two causes: either the specified size is a typo error (that is the
most probable cause) or the developer did not realize the size of the type he chose was too small.
Noncompliant code example
class A {
unsigned int b : 55; // Noncompliant, specified size is greater than the size of unsigned int
};
Compliant solution
class A {
unsigned int b : 32;
};
Or
class A {
unsigned long long int b : 55;
};