[previous] 0484 [next] [C] A pointer to an object of unknown size cannot be the operand of a subtraction 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 subtracting "1" from a pointer, the value of the pointer is not decremented 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 a subtraction operator.

For example:


/*PRQA S 488,510,3120,3198,3199,3203,3210,3227,3313,3408,3447,3681 ++*/

extern struct ST *sa;
extern struct ST *sb;

void foo(int n, void *pv)
{
    pv = pv - n;    /* Message 0484 */
    sa = sb - 2;    /* Message 0484 */
}

See also:

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