Versions Compared

Key

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

...

Noncompliant Code Example (ambiguous interface)

Code Block
bgColor#FFCCCC
/* compile using gcc4.3.3 */
void foo () {
    int i = 3;
    printf("i value: %d\n", i);
}

...

/* caller */
    foo(3);

In this particular example, caller gives a call to foo with parameter specified as 3. When compiled with gcc-4.3.3 in Linux, no warning will be issuedBecause function foo() is declared without void, the compiler will not perform caller check. Due to the accidental internal implementation, the function foo() outputs i value: 3 which matches with caller's temptation. In an inherited code base where foo and caller are developed at different time, this leads to caller's belief that foo actually accept one integer as parameter and foo will output the corresponding message when parameter is changed.

...