MISRA C++:2023 Rule 6.2.2
Description
This checker is deactivated in a default Polyspace® as You Code analysis . See Checkers Deactivated in Polyspace as You Code Analysis (Polyspace Access).
Rule Definition
All declarations of a variable or function shall have the same type.
Rationale
If the declarations of an object or function in two different translation units have incompatible types, the behavior is undefined.
Polyspace Implementation
Polyspace considers two types to be compatible if they have the same size and signedness in the environment that you use. The checker is not raised on unused code such as
Noninstantiated templates
Uncalled
static
orextern
functionsUncalled and undefined local functions
Unused types and variables
Polyspace reports a violation if you declare a function with a
[[noreturn]]
attribute in one translation unit, but another translation
unit that declares the same function does not use the [[noreturn]]
attribute.
Troubleshooting
If you expect a rule violation but Polyspace does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.
Examples
Check Information
Group: Basic Concepts |
Category: Required |
Version History
Introduced in R2024b