[previous] 0703 [next] Structure has fewer initializers than its declared size. Default initialization is applied to the remainder of the members.
Declarations and definitions REFERENCE - ISO:C90-6.5.7 Initialization - Semantics

The initialization of this struct is incomplete. The remaining members for which an initializer has not been specified will be initialized to zero; but is this the intention ?

If initialization is provided for some members of a struct, it is considered good practice to provide explicit initialization for all members, so as to avoid any uncertainty about the intention, An exception to this rule is the provision of a single braced initializer "{ 0 }". This is considered a satisfactory way of initializing the entire contents of the struct to zero. For example:


/*PRQA S 1305,2017,2213,3211,3408,3602 ++*/


struct s
{
  int i;
  int j;
} ;

const struct s s0    = {0};                      /* OK           */
const struct s s1    = {8};                      /* Message 0703 */

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents