[previous] MISRA C:2012  Rule-18.3:  (Required) [next] The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object

Example Code:


#include "misra.h"
#include "m3cmex.h"


extern int16_t rule_1803( void )
{
    int16_t   buf1[10];
    int16_t   buf2[10];
    int16_t * p1;
    int16_t * p2;
    int16_t * p3;

    p1 = buf1;
    p2 = buf2;

    if (p2 > p1)                                                /* 2771      */
    {
    }

    p3 = buf1;
    if (s16a > 0)
    {
        p3 = buf2;
    }

    if (p3 > p1)                                                /* 2772      */
    {
    }

    return 1;
}



QAC messages that encompass this guideline:

2771 Definite: These pointers address different objects.
2772 Apparent: These pointers address different objects.


Related rules:

Rule-18.2 Subtraction between pointers shall only be applied to pointers that address elements of the same array



(c) The Motor Industry Research Association, 2012
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents