Two or more incompatible declarations of the same function or object that appear in the same program shall be diagnosed because they result in undefined behavior.
The C Standard [ISO/IEC 9899:2011] identifies three distinct situations in which undefined behavior (UB) may arise as a result of incompatible declarations of the same function or object:
...
Code Block | ||||
---|---|---|---|---|
| ||||
/* a.c: */ int x = 0; /* The definition */ /* b.c: */ extern char x; /* Incompatible declaration */ /* butBut no other references to x */ |
...
Rule | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL40-C | lowLow | unlikelyUnlikely | mediumMedium | P2 | L3 |
Related Guidelines
CERT C Secure Coding Standard | ARR31-C. Use consistent array notation across all source files |
ISO/IEC TS 17961 | Declaring the same function or object in incompatible ways [funcdecl] |
...