[previous] 0483 [next] [C] A pointer to an object of unknown size cannot be the operand of an addition operator.
Constraint violations REFERENCE - ISO:C90-6.3.6 Additive Operators - Constraints

This is a constraint error

When performing any kind of pointer arithmetic, it is always necessary to know the size of the object being addressed. For example, when adding "1" to a pointer, the value of the pointer is not incremented by 1 byte but by the size (in bytes) of the type being addressed. For this reason, a pointer to an incomplete type cannot be the operand of an addition operator.

For example:


/*PRQA S 488,510,3227,3313,3408,3447 ++*/

extern struct ST *ps;
extern void *pv;

void foo(int n)
{
   ps = ps + n;       /* Message 483 */
   pv = pv + n;       /* Message 483 */
}


MISRA-C:2004 Rules applicable to message 0483:

Rule  1.1  (Required) All code shall conform to ISO/IEC 9899:1990 C programming language, ISO 9899, amended and corrected by ISO/IEC 9899/COR1:1995, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2: 1996192


See also:

QA·C Source Code Analyser 8.1
MISRA-C:2004 Compliance Module 3.2
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA-C:2004 Rule Index Contents