[previous] 0453 [next] [C] An array subscript must have integral type.
Constraint violations REFERENCE - ISO:C90-6.3.2.1 Array subscripting

This is a constraint error

The subscript expression is not of integral type. Only expressions of integral type can be used as an array subscript.

For example:


/*PRQA S 488,506,2106,2211,3121,3204,3227,3408,3447,3625,3673 ++*/

#define MAX 100
extern char barray[MAX];

void foo(int i, float f, int *pi)
{
    barray[i]   = '\0';        /* OK - integer index                  */
    barray[*pi] = '\0';        /* OK - integer index                  */
    barray[f]   = '\0';        /* Message 0453 - floating point index */
    barray[pi]  = '\0';        /* Message 0453 - pointer index        */

    *(barray + i)   = '\0';    /* OK                                  */
    *(barray + *pi) = '\0';    /* OK                                  */
    *(barray + f)   = '\0';    /* Message 0485                        */
    *(barray + pi)  = '\0';    /* Message 0485                        */
}


MISRA C:2012 Rules applicable to message 0453:

Rule-1.1  (Required) The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits


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