...
In this noncompliant code example, the comparison of a
to b
has no effect.:
Code Block | ||||
---|---|---|---|---|
| ||||
int a; int b; /* ... */ a == b; |
...
The assignment of b
to a
is now properly performed.:
Code Block | ||||
---|---|---|---|---|
| ||||
int a; int b; /* ... */ a = b; |
...
In this example, a pointer increment and then a dereference occur. However, but the dereference has no effect.:
Code Block | ||||
---|---|---|---|---|
| ||||
int *p; /* ... */ *p++; |
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
| NO_EFFECT | Finds statements or expressions that do not accomplish anything or statements that perform an unintended action. | |||||||
| noeffect | Partially implemented. | |||||||
GCC | 3.0 | Options detect unused local variables or nonconstant static variables and unused function parameters, respectively. | |||||||
| EFFECT |
| |||||||
| 65 D | Fully implemented. | |||||||
PRQA QA-C |
| 3110 | Partially implemented. | ||||||
Splint |
|
|
|
...
CERT C++ Secure Coding Standard | MSC12-CPP. Detect and remove code that has no effect |
ISO/IEC TR 24772 | Leveraging Human Experience [BRS] Unspecified Functionality [BVQ] Likely Incorrect Expressions [KOA] Dead and Deactivated Code [XYQ] |
MISRA - C:2012 | Rule 142.1 (required) Rule 142.2 (required) |
Bibliography
...