MISRA C:2012 Rule 21.22
All operand arguments to any type-generic macros declared in
<tgmath.h>
shall have an appropriate essential type
Since R2024a
Description
Rule Definition
All operand arguments to any type-generic macros declared in
<tgmath.h>
shall have an appropriate essential
type.
This rule comes from MISRA C™: 2012 Amendment 3.
Rationale
The type-generic macros declared in tgmath.h
support only arguments of essentially signed, essentially unsigned, or essentially floating types. Arguments of other types result in undefined behavior. For more information on essential types, see MISRA C:2012 Rule 10.1
.
A subset of these macros do not allow arguments of essentially complex floating types. For instance, the function atan2()
does not support complex arguments. For these macros, using arguments of essentially complex floating types result in undefined behavior.
Polyspace Implementation
The rule checker reports violations if a macro declared in tgmath.h
is used with arguments that have one of the following data types:
Essentially character.
Essentially boolean.
Essentially enum.
Essentially complex floating, if the macro does not support complex floating arguments.
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: Standard Libraries |
Category: Mandatory |
AGC Category: Mandatory |
Version History
Introduced in R2024a