![]() |
|
MISRA C:2012 Rule-18.4: (Advisory) |
|
||||
![]() | |||||||
Exception:
Subject to Rule-18.2, pointer subtraction between two pointers is allowed.
Example Code:
#include "misra.h"
#include "m3cmex.h"
extern int16_t rule_1804( void )
{
uint8_t ax[ 20 ];
uint8_t * ptr;
ptr = ax;
ptr ++; /* */ /* Compliant */
ptr = ptr + 1; /* */ /* Non-compliant */
ptr = ptr + 5; /* 0488 */ /* Non-compliant */
*( ptr + 5 ) = 0U; /* 0488 */ /* Non-compliant */
ptr[ 5 ] = 0U; /* */ /* Compliant */
return 1;
}
QAC messages that encompass this guideline:
| 0488 | Performing pointer arithmetic. |
|
||
(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 |