Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0

Wiki MarkupImmutable objects should be {{const}}\-qualified. Enforcing object immutability using {{const}}\-qualification helps ensure the correctness and security of applications. ISO/IEC TR 24772, for example, recommends labeling parameters as constant to avoid the unintentional modification of function arguments \[ [ISO/IEC TR 24772|AA. Bibliography#ISO/ISO/IEC DTR 24772]\]. See recommendation [STR05-C. Use pointers to const when referring to string literals] describes a specialized case of this recommendation.

Adding const qualification may propagate through a program; as you add const, qualifiers still more become necessary. This phenomenon is sometimes called const poisoning, which can frequently lead to violations of recommendation EXP05-C. Do not cast away a const qualification. While const qualification is a good idea, the costs may outweigh the value in the remediation of existing code.

...

Tool

Version

Checker

Description

Section

Compass/ROSE

 

 

 

Section

LDRA tool suite

Include Page
c:LDRA_Vc:
LDRA_V
Section

78 D
93 D
200 S

Section

Fully Implemented

...

ISO/IEC 9899:1999 Section 6.7.3, "Type qualifiers"

Bibliography

...

\[[Dewhurst 2002|AA. Bibliography#Dewhurst 02]\] Gotcha #25, "#define Literals" \[
[Saks 2000|AA. Bibliography#Saks 00]\]

...

02. Declarations and Initialization (DCL)      02. Declarations and Initialization (DCL)