Versions Compared

Key

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

Variadic functions accept a variable number of arguments but are problematic. Variadic functions define an implicit contract between the function writer and the function user that allows the function to determine the number of arguments passed in any particular invocation. Failure to enforce this contract may result in undefined behavior. See undefined behavior 141 of Appendix J of the C Standard [ISO/IEC 9899:2011].

...

In the following code example, the variadic function average() calculates the average value of the positive integer arguments passed to the function [Seacord 2005c]. The function processes arguments until it encounters an argument with the value of va_eol (-1).

...

Tool

Version

Checker

Description

LDRA tool suite

Include Page
LDRA_V
LDRA_V

41 S

Partially implemented

PRQA QA·CQA-C
Include Page
PRQA_V
PRQA_V
 Partially implemented

...

ISO/IEC 9899:2011 Section 7.16, "Variable arguments," and section 7.21.6.8, "The vfprintf function"

ISO/IEC TR 24772 "OTR Subprogram signature mismatch"

MISRA Rule 16.1

MITRE CWE: CWE-628, "Function call with incorrectly specified arguments"

Bibliography

[Seacord 2005c]

...