[previous] 2810 [next] Constant: Dereference of NULL pointer.
NULL pointers

An attempt has been made to dereference a null pointer constant. This is not an operation which the C language allows and it will result in undefined behaviour.

For example:


/*PRQA S 503,2017,2982,2983,2984,2986,3198,3199,3203,3408 ++*/

extern void foo(void)
{
    int r;

    r = *(int *)0;                   /* 2810 */
    
    r = *(int *)(void *)0;           /* 2810 */

}


MISRA-C:2004 Rules applicable to message 2810:

Rule  1.2  (Required) No reliance shall be placed on undefined or unspecified behaviour.
Rule  20.3  (Required) The validity of values passed to library functions shall be checked.


See also:

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