AutosarC++18_10-M5.0.14

The first operand of a conditional-operator shall have type bool

Required inputs: IR

Rationale

If an expression with type other than bool is used as the first operand of a conditional-operator, then its result will be implicitly converted to bool. The first operand shall contain an explicit test (yielding a result of type bool) in order to clarify the intentions of the developer.

Example
int32_a = int16_b ? int32_c : int32_d;           // Non-compliant 
int32_a = bool_b ? int32_c : int32_d; // Compliant
int32_a = ( int16_b < 5 ) ? int32_c : int32_d; // Compliant

Note

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