Versions Compared

Key

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

String literals are constant and should consequently be protected by the const qualification. This recommendation supports rule STR30-C. Do not attempt to modify string literals.

Adding const qualification may propagate through a program; as you add const qualifiers, still more become necessary. This phenomenon is sometimes called "const poisoning."

While const qualification is a good idea, the costs may outweigh the value when remediating existing code.

Non-Compliant Code Example

...

Recommendation

Severity

Likelihood

Remediation Cost

Priority

Level

STR05-A

1 ( low )

3 (likely)

2 (medium)

P6

unlikely

high

P1

L1 L2

Automated Detection

The LDRA tool suite V 7.6.0 is able to detect violations of this recommendation.

...