[previous] 2821 [next] Definite: Arithmetic operation on NULL pointer.
NULL pointers

A definite anomaly has been detected. Examination of the context indicates that this expression will always result in an arithmetic operation involving a null pointer.

The internal representation of a null pointer is implementation-defined and may not necessarily be bitwise 0. A null pointer may be assigned or compared, but any attempt to perform arithmetic operations will result in undefined behavior.

For example


/*PRQA S 489,508,2017,3205,3408,3673,4600 ++*/
#define NULL (void *)0

void foo(int *q)
{
    int *p;

    if (q == NULL)
    {
        ++q;                /* 2821 */
    }
}

See also:

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