[previous] 2840 [next] Constant: Dereference of an invalid pointer value.
Arrays

An element outside the bounds of an array is being accessed - either for reading or writing. Behaviour will be undefined.

For example:


/*PRQA S 488,2017,3120,3132,3199,3203,3408,3447 ++*/

extern int a[10];

extern int foo(void)
{
    int r;

    r = a[10];             /* 2840 */

    a[10] = 0;             /* 2840 */

    *(a + 10) = 0;         /* 2840 */

    return r;
}


MISRA C:2012 Rules applicable to message 2840:

Rule-1.3  (Required) There shall be no occurrence of undefined or critical unspecified behaviour


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