MISRAC++2023-12.2.3
In this section:
Synopsis
(Required) A named bit-field with signed integer type shall not have a length of one bit
Enabled by default
Yes
Severity/Certainty
Low/Low

Full description
Signed single-bit bitfields (excluding anonymous fields) were found. This check is identical to MISRAC++2008-9-6-4, MISRAC2004-6.5, MISRAC2012-Rule-6.2, STRUCT-signed-bit.
Coding standards
- MISRA C:2004 6.5
(Required) Bitfields of signed type shall be at least 2 bits long.
- MISRA C:2012 Rule-6.2
(Required) Single-bit named bit fields shall not be of a signed type
- MISRA C++ 2008 9-6-4
(Required) Named bit-fields with signed integer type shall have a length of more than one bit.
Code examples
The following code example fails the check and will give a warning:
struct S
{
signed int a : 1; // Non-compliant
};
The following code example passes the check and will not give a warning about this issue:
struct S
{
signed int b : 2;
signed int : 0;
signed int : 1;
signed int : 2;
};