...
| Code Block | ||||
|---|---|---|---|---|
| ||||
int *p1 = foo(); /* Removable if bar() does not produce any side effects */ (void)bar(); /* Removable if baz() does not produce any side effects */ (void)baz(); return p1; |
Exceptions
| Anchor | ||||
|---|---|---|---|---|
|
Risk Assessment
Unused values may indicate significant logic errors.
Recommendation | Severity | Likelihood | Detectable | RepairableRemediation Cost | Priority | Level |
|---|---|---|---|---|---|---|
MSC13-C | Low | Unlikely | Yes | MediumYes | P2P3 | L3 |
Automated Detection
Tool | Version | Checker | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Astrée |
| Supported, but no explicit checker | |||||||||||||||||
| CodeSonar |
| LANG.STRUCT.UUVAL | Unused value | ||||||||||||||||
| UNUSED_VALUE | Finds variables that are assigned pointer values returned from a function call but never used | |||||||||||||||||
| Helix QAC |
| C1500, C1502, C3203, C3205, C3206, C3207, C3229 DF2980, DF2981, DF2982, DF2983, DF2984, DF2985, DF2986 | |||||||||||||||||
| Klocwork |
| LV_UNUSED.GEN | |||||||||||||||||
| LDRA tool suite |
| 1 D, 8 D, 105 D, 94 D, 15 D | Fully implemented | ||||||||||||||||
| Parasoft C/C++test |
| MISRA2008-0_1_3_b | Fully implemented | CERT_C-MSC13-a | Avoid unnecessary local variables | ||||||||||||||
| PC-lint Plus |
| 438, 505, 529, 715, 838 | Partially supported | ||||||||||||||||
| Polyspace Bug Finder |
| Checks for: | Polyspace Bug Finder | R2016a
| Function prototype has parameters not read or written in function body Variable never read after assignment | Rec. partially covered. | |||||||||||||
| PVS-Studio |
| PRQA QA-C | |||||||||||||||||
| Include Page | PRQA QA-C_v | PRQA QA-C_v | 1500, 1502, 3203, 3205, 3206, 3207, 3229, 3196, 2980, 2981, 2982, 2983, 2984, 2985, 2986 | Fully implemented | PVS-Studio | 6.22 | V519, V596, V603, V714, V744, V751, V763, V1001, V5003 | ||||||||||||
| SonarQube C/C++ Plugin |
| S1854 |
...