[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 */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents