![]() |
|
MISRA-C:2004 Rule 17.3: (Required) |
|
||||
![]() | |||||||
Example Code:
#include "misra.h"
#include "m2cmex.h"
extern S16 test_1703( void )
{
S16 n = 0;
static S8 tab1[] = "test1";
static S8 tab2[] = "test2";
S8 * ptr1;
S8 * ptr2;
ptr1 = &tab1[ u16a ];
ptr2 = &tab1[ u16b ];
if ( ptr1 > ptr2 ) /* OK */
{
n = 1;
}
ptr2 = &tab2[ u16c ];
if ( ptr1 > ptr2 ) /* MISRA Violation */
{
n = 1;
}
return n;
}
QAC messages that encompass this guideline:
| 2771 | Definite: These pointers address different objects. |
| 2772 | Apparent: These pointers address different objects. |
Related rules:
| Rule 17.2 | Pointer subtraction shall only be applied to pointers that address elements of the same array. |
|
||
(c) The Motor Industry Research Association, 2004
|
QA C Source Code Analyser 8.1.2
MISRA-C:2004 Compliance Module 3.2 © 2013 Programming Research www.programmingresearch.com |
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index | Contents |