...
This compliant solution addresses the const
violation by not modifying the constant argument.:
Code Block | ||||
---|---|---|---|---|
| ||||
void foo(const int * x) { if (x != NULL) { printf("Value is %d\n", *x); } /* ... */ } |
...
In the first strcat_nc()
call, the compiler generates a warning about attempting to cast away const on str2
. This is because strcat_nc()
does not modify its second argument , yet fails to declare it const
.
...
In the final strcat_nc()
call, the compiler generates a warning about attempting to cast away const
on str4
. This , which is a valid warning.
Compliant Solution
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
Compass/ROSE |
|
| Can detect violations of this recommendation while checking for violations of recommendation DCL00-C. Const-qualify immutable objects. | ||||||
| cnstpnte | Fully implemented. | |||||||
| 62 D | Fully implemented. | |||||||
PRQA QA-C |
| 3673 | Fully implemented. |
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...