Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Wiki MarkupThe variable parameters of a variadic function, this that is, those that correspond with the position of the ellipsis, are interpreted by the {{va_arg()}} macro. The {{va_arg()}} macro is used to extract the next argument from an initialized argument list within the body of a variadic function implementation. The size of each parameter is determined by the specified type. If the type is inconsistent with the corresponding argument, the behavior is [undefined|BB. Definitions#undefined behavior] and may result in misinterpreted data or an alignment error \[[error (see EXP36-C. Do not convert pointers into more strictly aligned pointer types]\]).

The variable arguments to a variadic function are not checked for type by the compiler.  Therefore, So the programmer is responsible for ensuring that they are compatible with the corresponding parameter after the default argument promotions:

  • integer Integer arguments of types ranked lower than int are promoted to int, if int can hold all the values of that type, ; otherwise they are promoted to unsigned int (the "integer promotions");.
  • arguments Arguments of type float are promoted to double.

...

Wiki Markup
\[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]\] Section 6.5.2.2, "Function calls,"; and Section 7.15, "Variable arguments"

...