Versions Compared

Key

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

...

Attempting to compile a program with a function declarator that does not include the appropriate type information typically generates a warning but does not prevent program compilation. These warnings should be resolved. (See MSC00-C. Compile cleanly at high warning levels.)

Noncompliant Code Example (Non-Prototype-Format Declarators)

...

Declaring a function without any prototype forces the compiler to assume that the correct number and type of parameters have been supplied to a function. This can result in unintended and undefined behavior.

In this noncompliant code example, the definition of func() in file_a.c expects three parameters but is supplied only two.

...

C99 eliminated implicit function declarations from the C language. However, many compilers still allow the compilation of programs containing implicitly declared functions, although they may issue a warning message. These warnings should be resolved. (See MSC00-C. Compile cleanly at high warning levels.)

Compliant Solution (Function Prototypes)

...

Tool

Version

Checker

Description

LDRA tool suite

Include Page
LDRA_V
LDRA_V

21 S
135 S
170 S

Fully implemented.

GCC

Include Page
GCC_V
GCC_V

 

Can detect violation of this recommendation when the -Wstrict-prototypes flag is used.

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

decltype

Fully implemented.

PRQA QA-C
Include Page
PRQA_V
PRQA_V
 3335Fully implemented
  3450 
  0563 
  2050 

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...

ISO/IEC 9899:2011 Forward and Section 6.9.1, "Function definitions"

ISO/IEC TR 24772 "IHN Type system" and "OTR Subprogram signature mismatch"

MISRA Rule 8.2

Bibliography

[Spinellis 2006] Section 2.6.1, "Incorrect routine or arguments"

...