Versions Compared

Key

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

The C90 standard C Standard allows for implicit typing of variables and functions. Because implicit declarations lead to less stringent type checking, they can often introduce unexpected and erroneous behavior or even security vulnerabilities.

The C standard [ISO/IEC 9899:2011] The C Standard requires type identifiers and forbids implicit function declarations. After issuing the diagnostic, an implementation may choose to assume an implicit declaration and continue translation to support existing programs that used this feature.

Noncompliant Code Example (Implicit int)

C90 C allows for the absence of type specifiers in a declaration. In these cases, the type is defined to be that of a signed int.

Do not rely on implicit int typing. C11, Section 6.7.2 of the C Standard [ISO/IEC 9899:2011] , states:

At least one type specifier shall be given in the declaration specifiers in each declaration, and in the specifier-qualifier list in each struct declaration and type name.

...

Code Block
bgColor#FFCCCC
langc
extern foo;

Most C90 C implementations do not issue a diagnostic for the violation of this constraint. Many C translators will continue to treat such declarations as implying the type int.

...

However, to conform with the C standardStandard, you must explicitly prototype every function before invoking it. This noncompliant example fails to prototype the foo() function before invoking it in main().

...

ISO/IEC 9899:2011 Section 6.7.2, "Type specifiers," and Section 6.5.2.2, "Function calls"

ISO/IEC TR 24772 "OTR Subprogram signature mismatch"

MISRA

...

Sources

Jones 2008

...