MISRA C++:2008 Rule 3-9-2

typedefs that indicate size and signedness should be used in place of the basic numerical types

Description

Rule Definition

typedefs that indicate size and signedness should be used in place of the basic numerical types.

Rationale

When the amount of memory being allocated is important, using specific-length types makes it clear how much storage is being reserved for each object.

Polyspace Implementation

The rule checker does not raise violations in templates that are not instantiated.

Troubleshooting

If you expect a rule violation but do not see it, refer to the documentation for Polyspace® Code Prover™ or Polyspace Code Prover Server™.

Examples

expand all

typedef unsigned int uint32_t;

unsigned int x = 0;       //Noncompliant
uint32_t y = 0;  //Compliant

In this example, the declaration of x is noncompliant because it uses the basic type int directly.

Check Information

Group: Basic Concepts
Category: Advisory
Introduced in R2013b