MISRA C:2012 Rule 23.3
A generic selection should contain at least one non-default association
Since R2024a
Description
Rule Definition
A generic selection should contain at least one non-default association.
This rule comes from MISRA C™: 2012 Amendment 3.
Rationale
The default
association of a generic selection is selected without
any type checking when none of the nondefault associations can be selected. A
_Generic
statement that consists of only a
default
association always selects the default
selection and is not useful.
Include at-least one nondefault association in a generic selection. If you intend to
introduce a constraint violation when the types do not match in a generic selection,
omit the default
association.
Polyspace Implementation
Polyspace® reports a violation of this rule if a _Generic
statement contains only the default
association.
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: Advisory |
AGC Category: Advisory |
Version History
Introduced in R2024a