Comparing a function pointer to a value that is not a null function pointer of the same type will be diagnosed because it typically indicates programmer error and can result in unexpected behavior. Implicit comparisons will be diagnosed, as well.
...
Errors of omission can result in unintended program flow.
Recommendation | Severity | Likelihood |
|---|
Remediation CostDetectable | Repairable | Priority | Level |
|---|
EXP16-C | Low | Likely |
MediumAutomated Detection
Tool | Version | Checker | Description |
|---|
| Astrée | | function-name-constant-comparison
| Partially checked |
Coverity | | BAD_COMPARE | Can detect the specific instance where the address of a function is compared against 0, such as in the case of geteuid versus getuid() in the implementation-specific details |
| GCC | |
|
| Can detect violations of this recommendation when the -Wall flag is used |
| Helix QAC | | C0428, C3004, C3344 |
|
| Klocwork | | CWARN.NULLCHECK.FUNCNAME CWARN.FUNCADDR |
c:c:BDPBCCStricter checking than the definition here. | PRQA QA-Ca
| Function address should not be compared to zero |
| PC-lint Plus | |
PRQA QACvPRQA QAC_v3004, 3344, 428 | | 2440, 2441 | Partially supported: reports address of function, array, or variable directly or indirectly compared to null |
| PVS-Studio | | V516, V1058 |
|
| RuleChecker | | Include Page |
|---|
| RuleChecker_V |
|---|
| RuleChecker_V |
|---|
|
| function-name-constant-comparison
| Partially checked |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
Bibliography
| [Hatton 1995] | Section 2.7.2, "Errors of Omission and Addition" |
...
...
