...
Although this code appears to be well defined because of the prototype-less declaration of of buginf()
, it exhibits undefined behavior in accordance with the C Standard, 6.7.67.34, paragraph 15 14 [ISO/IEC 9899:20112024],
For two function types to be compatible, both shall specify compatible return types. Moreover, the parameter type lists , if both are present, shall agree in the number of parameters and in use of the final ellipsis terminator; corresponding parameters shall have compatible types. If one type has a parameter type list and the other type is specified by a function declarator that is not part of a function definition and that contains an empty identifier list, the parameter list shall not have an ellipsis terminator and the type of each parameter shall be compatible with the type that results from the application of the default argument promotionsIn the determination of type compatibility and of a composite type, each parameter declared with function or array type is taken as having the adjusted type and each parameter declared with qualified type is taken as having the unqualified version of its declared type.
Compliant Solution (Incompatible Variadic Function Declarations)
...
Tool | Version | Checker | Description | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Astrée |
| type-compatibility type-compatibility-link distinct-extern | Fully checked | ||||||||||||||||||||||
Axivion Bauhaus Suite |
| CertC-DCL40 | Fully implemented | ||||||||||||||||||||||
CodeSonar |
| LANG.STRUCT.DECL.IF LANG.STRUCT.DECL.IO | Inconsistent function declarations Inconsistent object declarations | ||||||||||||||||||||||
Coverity |
| MISRA C 2012 Rule 8.4 | Implemented | ||||||||||||||||||||||
Cppcheck Premium |
| premium-cert-dcl40-c | Partially implemented | ||||||||||||||||||||||
Helix QAC |
| C0776, C0778, C0779, C0789, C1510 C++1510 | Fully implemented | ||||||||||||||||||||||
Klocwork |
| MISRA.FUNC.NOPROT.DEF.2012 | Fully implemented | ||||||||||||||||||||||
LDRA tool suite | 8.5.4 | 1 X, 17 D | Partially implemented | ||||||||||||||||||||||
Parasoft C/C++test |
| CERT_C-DCL40-a | A declaration shall be visible when All declarations of an object or function | with external linkage is definedshall have compatible types | |||||||||||||||||||||
Parasoft Insure++ | Runtime analysis | ||||||||||||||||||||||||
PC-lint Plus |
| 18, 621, 793, 4376 | Fully supported | ||||||||||||||||||||||
Polyspace Bug Finder |
| Checks for declaration mismatch (rule fully covered) | Polyspace Bug Finder | ||||||||||||||||||||||
Include Page | Polyspace Bug Finder_V | Polyspace Bug Finder_V | Mismatch between function or variable declarations External identifiers shall be distinct All declarations of an object or function shall use the same names and type qualifiers | PRQA QA-C | |||||||||||||||||||||
Include Page | PRQA QA-C_v | PRQA QA-C_v | 1510,776,778,779,789 | Fully implemented | PRQA QA-C++ | Include Page | | cplusplus:PRQA QA-C++_V | cplusplus:PRQA QA-C++_V | ||||||||||||||||
RuleChecker |
| type-compatibility type-compatibility-link distinct-extern
| Fully checked | ||||||||||||||||||||||
TrustInSoft Analyzer |
| incompatible declaration | Exhaustively verified. |
Related Guidelines
Key here (explains table format and definitions)
...
[Hatton 1995] | Section 2.8.3 | |||
[ISO/IEC 9899:2011] | J.2, "Undefined Behavior" | |||
[ISO/IEC 9899:2024] | 6.7. | 67. | 3, 4 "Function Declarators | (including Prototypes)"" |
...