[previous] 0507 [next] [u] Arithmetic operation on constant NULL pointer.
Dataflow - NULL pointers REFERENCE - ISO:C90-6.2.2.3 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,2017,3199,3203,3408 ++*/

#define NULL (void *)0

extern void foo(void)
{
    int *p;

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

See also:

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