MISRA C:2023 Rule 23.6
The controlling expression of a generic selection shall have an essential type that matches its standard type
Since R2024a
Description
Rule Definition
The controlling expression of a generic selection shall have an essential type that matches its standard type.
Rationale
When you develop your code under the MISRA guidelines, it must follow the essential type system. If the controlling expression of a generic selection has standard type that is different than its essential type, then the generic selection violates the essential type system.
As an exception, this rule does not apply to integer constant expression that satisfy both these conditions:
The integer constant expression has an essentially signed or unsigned type of lower rank than
int
.It is neither character constant nor Boolean.
Polyspace Implementation
Polyspace® reports a violation of this rule if the essential type of an expression is
different from its standard type. Integer constants that are of lower rank than
int
and are neither char
nor bool
are not a violation of this rule.
Troubleshooting
If you expect a rule violation but do not see it, refer to Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Generic Selections |
Category: Required |
AGC Category: Required |
Version History
Introduced in R2024a