AutosarC++18_03-M5.0.18

>, >=, <, <= shall not be applied to objects of pointer type, except where they point to the same array

Required inputs: IR, StaticSemanticAnalysis

Rationale

Attempting to make comparisons between pointers will produce undefined behaviour if the two pointers do not point to the same object.

Note: it is permissible to address the next element beyond the end of an array, but accessing this element is not allowed.

Example
void f1 (  ) 
{
int32_t a1[ 10 ];
int32_t a2[ 10 ];
int32_t * p1 = a1;
if ( p1 < a1 ) // Compliant
{
}
if ( p1 < a2 ) // Non-compliant
{
}
}

Note

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