Versions Compared

Key

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

String literals are constant and should consequently be protected by const qualification. This recommendation is a specialization of DCL00-A. Const-qualify immutable objects and also 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." Const-poisoning can frequently lead to violations of EXP05-A. Do not cast away a const qualification. While const qualification is a good idea, the costs may outweigh the value when remediating in the remediation of existing code.

Non-Compliant Code Example

...