 
                            ...
In this example, p2 is assigned the value returned by bar(), but that value is never used. Note this example assumes that foo() and bar() return valid pointers. (See DCL30-C. Declare objects with appropriate storage durations.)
| Code Block | ||||
|---|---|---|---|---|
| 
 | ||||
| int *p1, *p2;
p1 = foo();
p2 = bar();
if (baz()) {
  return p1;
}
else {
  p2 = p1;
}
return p2;
 | 
...
| Tool | Version | Checker | Description | ||||||
|---|---|---|---|---|---|---|---|---|---|
| 
 | 1 D | Fully implemented. | |||||||
| 
 | UNUSED_VALUE | Finds variables that are assigned pointer values returned from a function call but never used. | |||||||
| 
 | 
 | Can detect violations of this rule with a number of checkers. | |||||||
| PRQA QA·C | 
 | Fully implemented | 
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...
CERT C++ Secure Coding Standard: MSC13-CPP. Detect and remove unused values
ISO/IEC TR 24772 "BRS Leveraging human experience," "KOA Likely incorrect expressions," "XYQ Dead and deactivated code," and "XYR Unused variable"
Sources
...