Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

In the second strcat_nc() call, the compiler compiles the code with no warnings, but the resulting code will attempt to modify the "str1" literal. This violates STR05-C. Use pointers to const when referring to string literals and STR30-C. Do not attempt to modify string literals.

In the final strcat_nc() call, the compiler generates a warning about attempting to cast away const on str4. This is a valid warning.

...

Not declaring an unchanging value const prohibits the function from working with values already cast as const. This problem can be sidestepped by type casting away the const, but doing so violates EXP05-C. Do not cast away a const qualification.

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

DCL13-C

low

unlikely

low

P3

L3

...

Tool

Version

Checker

Description

Compass/ROSE

 

 

Can detect violations of this recommendation while checking for violations of recommendation DCL00-C. Const-qualify immutable objects.

LDRA tool suite

Include Page
LDRA_V
LDRA_V

62 D

Fully implemented.

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

cnstpnte

Fully implemented.

PRQA QA·CQA-C
Include Page
PRQA_V
PRQA_V
 Fully implemented

...

CERT C++ Secure Coding Standard: DCL13-CPP. Declare function parameters that are pointers to values not changed by the function as const

ISO/IEC 9899:2011

ISO/IEC TR 24772 "CSJ Passing parameters and return values"

...