[previous] 2820 [next] Constant: Arithmetic operation on NULL pointer.
NULL pointers

Pointer arithmetic is being performed on a null pointer constant.

Internal representation of a null pointer constant is implementation-defined and may not necessarily be bitwise 0. A null pointer constant may be assigned or compared, but any attempt to perform arithmetic operations on it should be viewed as suspicious and non-portable.

For example:


/*PRQA S 489,507,2017,2983,2986,3199,3203,3408,4600 ++*/

#define NULL (void *)0

extern void foo(void)
{
    int *p;

    p = (int *)(NULL) + 1 ;            /* 2820 */
}

See also:

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