According to the C ++ 11 standard ยง9.6 / p3 Bit-fields [class.bit] ( Mine Accent ):
The bit field must not be a static member. The bit field must be of an integral or enumerated type (3.9.1). Whether it is a regular (without explicitly signed or unsigned) char , short , int , long or long long bit-field is signed or not specified. The value of A bool can be successfully stored in a bit field of any nonzero size. operator address and should not be applied to a bit field, therefore, are not pointers to bit fields. A non-constant reference must not be connected to a bit field (8.5.3). [Note: if the initializer for the reference is of type const T & is an l value that refers to a bit field, the link is bound to a temporary bit field initialized to store the value; the link is not attached directly to the bit field. See 8.5.3. -end note]
So, you are right for the first part. Indeed, prior to C ++, 14 bits of the structure field declared as signed still interpreted as signed or unsigned , and the interpretation was implemented.
As mentioned in this comment by @TC . Defect reports related to the problem were made by DR739 , DR675 . Result in the following permissions in the C ++ 14 standard:
The wording "Defined by the implementation of whether signed, unsigned, one-explicit (without explicitly signed or unsigned) char , short , int , long or long long .", Was deleted, and now the C ++ 14 wording:
The bit field must not be a static member. The bit field must be of an integral or enumerated type (3.9.1). The bool value can be successfully stored in a bit field of any nonzero size. The operator address & should not be applied to a bit field, so there are no pointers to bit fields. A non-constant reference must not be bound to a bit field (8.5.3). [Note: if the initializer for a link of type const T & is an l value that refers to a bit field, the link is bound to a temporary initialization to store the value of the bit field; the link is not attached directly to the bit field. See 8.5.3. -end note]
Also in ยงC .1.8, section 9: classes [diff.class], the following section was added:
9.6
Edit: Bit fields of type plain int are signed.
Rationale: Leaving a choice of signature for implementation may result in inconsistent definitions of specialized templates. To ensure consistency, freedom of implementation has been eliminated for type-independent too.
Impact on the original function:. The choice is determined by the implementation in C, but not so in C ++.
Transformation Complexity: Syntactic Transformation.
How widely used: Rarely.
Therefore, in C ++ 14, plain int bits are signed , and the submitted code is guaranteed to work as intended.