Variadic function

For instance, C's printf, if used incautiously, can give rise to a class of security holes known as format string attacks.

The attack is possible because the language support for variadic functions is not type-safe: it permits the function to attempt to pop more arguments off the stack than were placed there, corrupting the stack and leading to unexpected behavior.

As a consequence of this, the CERT Coordination Center considers variadic functions in C to be a high-severity security risk.

However they are referring to the same phenomenon, and sometimes the phrasing is mixed, resulting in names such as variadic variable (synonymous to hedge).

To portably implement variadic functions in the C language, the standard stdarg.h header file is used.

In some other cases, for example printf, the number and types of arguments are figured out from a format string.

(Alternatively, a sentinel value like NULL or nullptr may be used to indicate the end of the parameter list.)

At the calling site, you can either list the arguments one by one, or hand over a pre-existing array having the required element type.

The basic variadic facility in C++ is largely identical to that in C. The only difference is in the syntax, where the comma before the ellipsis can be omitted.

Variadic templates (parameter pack) can also be used in C++ with language built-in fold expressions.

[8] fmt.Println is a common variadic function; it uses an empty interface as a catch-all type.

Nonetheless, dialects of Pascal implement mechanisms resembling variadic routines.

Delphi defines an array of const data type that may be associated with the last formal parameter.

[13] Both GNU Pascal and FreePascal allow externally declared functions to use a variadic formal parameter specification using an ellipsis (...).

Keyword arguments can be stored in a dictionary, e.g. def bar(*args, **kwargs).