MISRA C++:2023 Rule 8.2.11
Description
Rule Definition
An argument passed via ellipsis shall have an appropriate type.
Rationale
Passing arguments of certain class types via ellipsis is only conditionally supported, subject to implementation-defined semantics.
For instance, if an argument of a class type with a nontrivial copy constructor is passed via ellipsis, the copy constructor might not be called. As a result, the copy semantics in the constructor might not be enforced properly.
Polyspace Implementation
Based on the MISRA™ C++:2023 specifications, the rule checker reports violations if an argument passed to a variadic function via ellipsis has a class type with one of the following:
Nontrivial copy or move operations
Nontrivial destructor
Virtual member functions
The checker allows passing of such arguments if the function call is not evaluated, for instance, when the function call is used as argument to one of sizeof
, typeid
, decltype
or noexcept
.
The rule violation is shown on the invocation of the variadic function. The result message indicates the reasons why the argument passed via ellipsis does not have an appropriate data type. The event list below the result message shows the location where the argument data type is defined.
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: Expressions |
Category: Advisory |
Version History
Introduced in R2024b