C and C++


LANG.STRUCT.INIT.PIARR : 一部未初期化のある配列

要旨

配列の一部が未初期化で、かつ初期化子は文字列リテラル、初期化子 {0}、指示初期化子ではありません。

プロパティ

クラス名 Partially Uninitialized Array
日本語クラス名 一部未初期化のある配列
クラス分類 スタイル (style)
ニーモニック LANG.STRUCT.INIT.PIARR
カテゴリー
MisraC2023 MisraC2023:9.3 Arrays shall not be partially initialized
Misra2012 Misra2012:9.3 Arrays shall not be partially initialized
Misra2004 Misra2004:9.2 Braces shall be used to indicate and match the structure in the non-zero initialisation of arrays and structures
MisraC++2023 MisraC++2023:11.6.1 All variables should be initialized
CWE CWE:1419 Incorrect Initialization of Resource
JSF++ JSF++:144 Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっており、プロジェクトには非正規の C向けAST が必要になります。有効にするにはプロジェクト設定ファイル (configuration file) に以下の WARNING_FILTER ルールと RETAIN_UNNORMALIZED_C_AST 設定を追加してください。
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Partially Uninitialized Array"
注:非正規化された AST を継続して使用した場合、使用ディスク容量が増加し解析時間が長くなる可能性があります。

int arr_partial[100] = {1,2,3}; /* 'Partially Uninitialized Array' warning issued here */      

char arr_partialstr[100] = "hello";                     /* string literal */  

int arr_partialzero[100] = {0};                         /* {0} initializes all elements to 0 */  

int arr_partialdes[100] = {[5]=0, [22]=6};              /* designated initializer */

関連のある設定ファイルパラメータ

設定ファイルの以下のパラメータがこのワーニングクラスのチェックに影響します。