Versions Compared

Key

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

Do not cast away a const qualification on an object of pointer type. Casting away the const qualification allows a program to modify the object referred to by the pointer, which may result in undefined behavior. See undefined behavior 64 in Appendix J of the C standard [ISO/IEC 9899:2011].

...

Tool

Version

Checker

Description

LDRA tool suite

Include Page
LDRA_V
LDRA_V

203 S

Fully implemented.

GCC

Include Page
GCC_V
GCC_V

 

Can detect violations of this recommendation when the -Wcast-qual flag is used.

Compass/ROSE

 

 

 

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

castexpr

Fully implemented.

PRQA QA-C
Include Page
PRQA_V
PRQA_V
 0311Fully implemented

Related Vulnerabilities

...

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

ISO/IEC PDTR 24772 "HFC Pointer casting and pointer type changes" and "IHN Type system"

MISRA Rule 11.5

MITRE CWE: CWE-704, "Incorrect type conversion or cast"

...