AutosarC++18_10-A8.4.1¶
Functions shall not be defined using the ellipsis notation
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
Passing arguments via an ellipsis bypasses the type checking performed by the compiler. Additionally, passing an argument with non-POD class type leads to undefined behavior.
Variadic templates offer a type-safe alternative for ellipsis notation. If use of a variadic template is not possible, function overloading or function call chaining can be considered.
Example
// $Id: A8-4-1.cpp 289436 2017-10-04 10:45:23Z michal.szczepankiewicz $
void Print1(char* format, ...) // Non-compliant - variadic arguments are used
{
// ...
}
template <typename First, typename... Rest>
void Print2(const First& first, const Rest&... args) // Compliant
{
// ...
}
See Also
- MISRA C++ 2008 [7]: Rule 8-4-1 Functions shall not be defined using the ellipsis notation.
- HIC++ v4.0 [9]: 14.1.1 Use variadic templates rather than an ellipsis.
- C++ Core Guidelines [11]: Type.8: Avoid reading from varargs or passing vararg arguments. Prefer variadic template parameters instead.
- C++ Core Guidelines [11]: F.55: Don’t use va_arg arguments.
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
ellipsis_parameter |
Function definitions shall not use ellipsis |
None |
False |
Options¶
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
ignore_declarations¶
ignore_declarations : bool = True
ignore_inherited¶
ignore_inherited : bool = False