Why is this an issue?
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. Note that the rule specifies "defined" (and not "declared") so as to permit the use of existing library functions.
Noncompliant code example
void MyPrintf ( char_t * pFormat, ... ) // Noncompliant
{
// ...
}
Resources
- MISRA C:2004, 16.1 - Functions shall not be defined with a variable number of arguments.
- MISRA C++:2008, 8-4-1 - Functions shall not be defined using the ellipsis notation.
- CERT, DCL50-CPP. - Do not define a C-style variadic function
- C++ Core
Guidelines ES.34 Don’t define a (C-style) variadic function
- C++ Core Guidelines
F.55 Don’t use va_arg arguments