MISRA C++:2008 Rule 0-1-12
There shall be no unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it
Description
Rule Definition
There shall be no unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it.
Rationale
Unused parameters often indicate later design changes. You perhaps removed all uses of a specific parameter but forgot to remove the parameter from the parameter list.
Unused parameters constitute an unnecessary overhead. You can also inadvertently call the function with a different number of arguments causing a parameter mismatch.
Polyspace Implementation
For each virtual function, the checker looks at all overrides of the function. If an override has a named parameter that is not used, the checker shows a violation on the original virtual function and lists the override as a supporting event.
Note that Polyspace checks for unused parameters in virtual functions within single translation units. For instance, if a base class contains a virtual method with an unused parameter but the derived class implementation of the method uses that parameter, the rule is not violated. However, if the base class and derived class are defined in different files, the checker, which operates file by file, flags a violation of this rule on the base class.
The checker does not flag unused parameters in functions with empty bodies.
Additional Message in Report
There shall be no unused parameters (named or unnamed) in the set of parameters for a virtual function and all the functions that override it.
Function
has unused
parameters. funcName
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 R2016b