[previous] 2811 [next] Definite: Dereference of NULL pointer.
NULL pointers

A definite anomaly has been detected. Examination of the context indicates that this expression will always result in the dereferencing of a null pointer. The result of any attempt to dereference a null pointer value is undefined.

In the example below, p is NULL throughout the code contained in the "if" block and the result of the dereferencing operation will always be undefined.


/*PRQA S 504,2017,2983,2986,3199,3203,3227,3408,3412,3673,4600 ++*/
#define NULL (void *)0

void foo(int *p)
{
    int r;

    if (p == NULL)
    {
        r = *p;             /* 2811 */
    }
}


MISRA C:2012 Rules applicable to message 2811:

Dir-4.1  (Required) Run-time failures shall be minimized


See also:

QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents