Versions Compared

Key

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

...

When working with sizeof(), keep in mind recommendation ARR01-C. Do not apply the sizeof operator to a pointer when taking the size of an array.

...

Tool

Version

Checker

Description

LDRA tool suite

Include Page
LDRA_V
LDRA_V

201 S

Fully implemented

Compass/ROSE

 

 

Could detect violations of this recommendation merely by searching for the use of "magic numbers" and magic strings in the code itself. That is, any number (except a few canonical numbers: −1, 0, 1, 2) that appears in the code anywhere besides where assigned to a variable is a magic number and should instead be assigned to a const integer, enum, or macro. Likewise, any string literal (except "" and individual characters) that appears in the code anywhere besides where assigned to a char* or char[] is a magic string.

ECLAIR

Include Page
ECLAIR_V
ECLAIR_V

nomagicc

Fully implemented.

Related Vulnerabilities

Search for vulnerabilities resulting from the violation of this rule on the CERT website.

...

CERT C++ Secure Coding Standard: DCL06-CPP. Use meaningful symbolic constants to represent literal values in program logic

ISO/IEC 9899:2011 Section  Section 6.3.2.1, "Lvalues, arrays, and function designators," Section 6.7, "Declarations," Section 6.7.2.2, "Enumeration specifiers," and Section 6.10.3, "Macro replacement"

...