Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: updated parasoft

...

The C Standard identifies four situations in which undefined behavior (UB) may arise as a result of incompatible declarations of the same function or object:

UB

Description

Code

15

Two declarations of the same object or function specify types that are not compatible (6.2.7).

All noncompliant code in this guideline

31Two identifiers differ only in nonsignificant characters (6.4.2.1).Excessively Long Identifiers

37

An object has its stored value accessed other than by an lvalue of an allowable type (6.5).

Incompatible Object Declarations
Incompatible Array Declarations

41

A function is defined with a type that is not compatible with the type (of the expression) pointed to by the expression that denotes the called function (6.5.2.2).

Incompatible Function Declarations 
Excessively Long Identifiers

Although the effect of two incompatible declarations simply appearing in the same program may be benign on most implementations, the effects of invoking a function through an expression whose type is incompatible with the function definition are typically catastrophic. Similarly, the effects of accessing an object using an lvalue of a type that is incompatible with the object definition may range from unintended information exposure to memory overwrite to a hardware trap.

...

Code Block
bgColor#ccccff
langc
/* In bashline.h */
extern char * bash_groupname_completion(const char *, int);   

/* In a.c */
#include "bashline.h"

void f(const char *s, int i) {
  bash_groupname_completion(s, i);  
}

/* In b.c */
int bash_groupname_completion_funct; 

Risk Assessment

Rule

Severity

Likelihood

Remediation Cost

Priority

Level

DCL40-C

Low

Unlikely

Medium

P2

L3

Automated Detection

Tool

Version

Checker

Description

Astrée
Include Page
Astrée_V
Astrée_V

type-compatibility

Partially checked
CodeSonar
Include Page
CodeSonar_V
CodeSonar_V
LANG.STRUCT.DECL.IF
LANG.STRUCT.DECL.IO
Inconsistent function declarations
Inconsistent object declarations
Coverity
Include Page
Coverity_V
Coverity_V
MISRA C 2012 Rule 8.4Implemented
LDRA tool suite8.5.4

1 X, 17 D

Partially implemented
Parasoft C/C++test

Include Page
Parasoft_V
Parasoft_V

CODSTA-118, MISRA2004-8_4Implemented
Parasoft Insure++
  

Include Page
Parasoft_V
Parasoft_V


runtime
Polyspace Bug FinderR2016aDeclaration mismatch

Mismatch between function or variable declarations

PRQA QA-C
Include Page
PRQA QA-C_v
PRQA QA-C_v
1510,776,778,779,789Fully implemented
PRQA QA-C++
Include Page
cplusplus:PRQA QA-C++_V
cplusplus:PRQA QA-C++_V

1510

 

RuleChecker
Include Page
RuleChecker_V
RuleChecker_V

type-compatibility


Partially checked

Related Guidelines

Key here (explains table format and definitions)

Taxonomy

Taxonomy item

Relationship

ISO/IEC TS 17961Declaring the same function or object in incompatible ways [funcdecl]Prior to 2018-01-12: CERT: Unspecified Relationship
MISRA C:2012Rule 8.4 (required)Prior to 2018-01-12: CERT: Unspecified Relationship

Bibliography

[Hatton 1995]Section 2.8.3
[ISO/IEC 9899:2011]6.7.6.3, "Function Declarators (including Prototypes)"
J.2, "Undefined Behavior"

...


...