AutosarC++19_03-A8.4.1

Functions shall not be defined using the ellipsis notation

Required inputs: IR

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

ignore_declarations

ignore_declarations : bool = True

Allow declarations of functions with variable number of arguments (e.g. for existing library functions); only report definitions.
 

ignore_inherited

ignore_inherited : bool = False

Do not report functions inheriting a variable number of arguments.