
Inline adoc files when they are included exactly once. Also fix language tags because this inlining gives us better information on what language the code is written in.
45 lines
824 B
Plaintext
45 lines
824 B
Plaintext
== Why is this an issue?
|
|
|
|
The values which may be represented by a bit-field of length one may not meet developer expectations. Anonymous signed bit-fields of any length are allowed.
|
|
|
|
|
|
=== Noncompliant code example
|
|
|
|
[source,cpp]
|
|
----
|
|
struct S
|
|
{
|
|
signed int a : 1; // Noncompliant, signed fields require at least two bits
|
|
signed int : 1; // Compliant, cannot be referenced
|
|
signed int : 0; // Compliant, cannot be referenced
|
|
};
|
|
----
|
|
|
|
|
|
=== Compliant solution
|
|
|
|
[source,cpp]
|
|
----
|
|
struct S
|
|
{
|
|
signed int a : 2; // Compliant
|
|
signed int : 1; // Compliant, cannot be referenced
|
|
signed int : 0; // Compliant, cannot be referenced
|
|
};
|
|
----
|
|
|
|
|
|
== Resources
|
|
|
|
* MISRA {cpp}:2008, 9-6-4
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
=== duplicates: S2216
|
|
|
|
endif::env-github,rspecator-view[]
|