![]() |
![]() |
0686 | ![]() |
||||
![]() | |||||||
| Declarations and definitions | REFERENCE - ISO:C90-6.5.7 Initialization - Semantics | ||||||
The initialization of this array is incomplete. The remaining elements for which an initializer has not been specified will be initialized to zero; but is this the intention ? If initialization is provided for some elements of an array, it is considered good practice to provide explicit initialization for all elements, 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 an array to zero. For example:
/*PRQA S 2017,2213,3120,3132,3211,3408 ++*/
int buf1[4] = { 0 }; /* OK */
int buf2[4] = { 1, 2, 3, 4 }; /* OK */
int buf3[4] = { 1, 2, 3 }; /* Message 0686 */
int buf4[3][3] = {{0},{1, 2, 3}, {4, 5, 6} }; /* OK */
int buf5[3][3] = { { 1, 2, 3 } }; /* Message 0686 */
![]() | ||
| QA·C Source Code Analyser 8.1.2
© 2013 Programming Research. www.programmingresearch.com | Personality Groups | Glossary | Message Index | Contents |