AutosarC++18_03-M5.0.3

A cvalue expression shall not be implicitly converted to a different underlying type

Required inputs: IR

Rationale

In order to ensure all operations in an expression are performed in the same underlying type, an expression defined as a cvalue shall not undergo further implicit conversions.

Example
void f ( ) 
{
int32_t s32;
int8_t s8;
s32 = s8 + s8; // Example 1 –
// Non-compliant
s32 = static_cast < int32_t > ( s8 ) + s8; // Example 2 - Compliant
s32 = s32 + s8; // Example 3 - Compliant
}

In Example 1, the addition operation is performed with an underlying type of int8_t and the result is converted to an underlying type of int32_t.

In Examples 2 and 3, the addition is performed with an underlying type of int32_t and therefore no underlying type conversion is required.

Note

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