AutosarC++17_10-M0.1.4

A project shall not contain non-volatile POD variables having only one use

Required inputs: IR

Rationale

With the exception of volatile variables, variables declared and used only once do not contribute to program computations. A use is either an assignment (explicit initialization) or a reference.

These variables are essentially noise but their presence may indicate that the wrong variable has been used elsewhere. Missing statements contribute to this problem.

Example
const int16_t x = 19;        // Compliant 
const int16_t y = 21; // Non-compliant
void usedonlyonce ( void )
{
int16_t once_1 = 42; // Non-compliant
int16_t once_2;
once_2 = x ; // Non-compliant
}

Note that x is compliant as there are two uses, firstly when initialized and secondly when assigned to once_2.

Note

For legal reasons, this rule’s description is not part of the public documentation.