MISRA C++:2023 Rule 6.2.1
Description
Rule Definition
The one-definition rule shall not be violated.
Rationale
Violations of the one definition rule (ODR) leads to undefined behavior. The ODR is violated when an entity in you code:
Does not have a definition.
Has multiple noninline definitions in different source files.
Has multiple different inline definitions in different source files.
Has different initializer values.
Polyspace Implementation
The rule checker reports violations when:
The same function or object has multiple definitions and the definitions differ by some token.
An inline function has different implementations in different source files.
The checker is not raised on unused code such as
Noninstantiated templates
Uncalled
static
orextern
functionsUncalled and undefined local functions
Unused types and variables
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