[previous] 0941 [next] [C] A variable length array may not be initialized.
Constraint violations REFERENCE - ISO:C99-6.7.8 Initialization - Constraints

This is a constraint error

When an array is defined with variable length, it is not permitted to specify an initializer. For example:


/* PRQA S 1051,2213,2215,3122,3205,3227,3408,3604,3625 ++ */

void foo(int n)
{
    char bc1[n] = {0};            /* Message 0941 */
    char bc2[n] = "<DEFAULT>";    /* Message 0941 */
}


MISRA C:2012 Rules applicable to message 0941:

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


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