MISRA C++:2023 Rule 0.2.2
Description
Rule Definition
A named function parameter shall be used at least once 1
Rationale
Unused parameters of a function can indicate programming errors or incomplete code. For instance, the parameter might be intended for an operation that you forgot to code.
Polyspace Implementation
The rule checker reports violations on unnamed unused parameters of a function except in the following cases:
The function has an empty body.
The function contains Assembly language instructions (which might be using the parameters).
The parameters are declared with the attribute
[[maybe_unused]]
.
If a rule violation is reported, the result details for the violation shows which function parameters are unused.
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: Language independent issues |
Category: Required |
Version History
Introduced in R2024b
1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.