[previous] 3604 [next] Using an initializer when defining an automatic object of struct, union or array type.
K+R compatibility

A local array, structure or union with automatic storage duration is being initialized. This was not permitted in early versions of the C language.

Message 3604 is functionally identical to message 0351 except that message 3604 is only generated when the "-k+r a" option is disabled and message 0351 is only generated when this option is enabled.

For example:


/*PRQA S 750,759,2017,2211,2213,2216,3120,3122,3132,3205,3223,3408,3625,3674 ++*/

struct ST {int x; int y;};
union  UN {unsigned int ui;unsigned char uc[4];};

extern void foo(void)
{
   static char a[] = "123456";          /*              */

   char c1[] = "abcdefg";               /* Message 3604 */
   char c2[] = "abcdefg";               /* Message 3604 */

   int  n1[] = { 1, 2, 3, 4 };          /* Message 3604 */
   int  n2[] = { 1, 2, 3, 4 };          /* Message 3604 */

   struct ST stx = { 10, 12 };          /* Message 3604 */
   struct ST sty = { 10, 12 };          /* Message 3604 */

   union  UN unx = { 2 };               /* Message 3604 */
   union  UN uny = { 2 };               /* Message 3604 */
}


No MISRA C:2012 Rules applicable to message 3604


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