C and C++ Binaries


LANG.STRUCT.UC : 到達不能コード

要旨

エントリポイント関数から到達不能なコードが存在しています。

以下は到達不能コードのワーニングクラスの一覧で、重要度の高い順に並んでいます。 到達不能コードの検出は、該当する最も重要なクラスが適用されます。

ワーニングクラス名 到達不能における最も深刻な状況の分類
到達不能な関数呼び出し 関数呼び出しに到達しない
到達不能な計算 (加算命令の様な)計算命令に到達しない
到達不能な条件 if, while, switch, ?, &&, || などの分岐に到達しない
到達不能なデータフロー 単純な代入文や値を返す return 文に到達しない
到達不能なコントロールフロー break, goto, continue, 値を返さない return 文などのコントロールフローに到達しない

プロパティ

複数のワーニングクラスでこのニーモニックを共有しています。

これらを全て有効もしくは無効にするには、プ ロジェクト設定ファイル(configuration file)に以下の WARNING_FILTER ルールを追加し てください。

WARNING_FILTER += allow categories:LANG.STRUCT.UC
WARNING_FILTER += discard categories:LANG.STRUCT.UC
クラス名 Unreachable Call
日本語クラス名 到達不能な関数呼び出し
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.UC
カテゴリー
MisraC2023 MisraC2023:2.1 A project shall not contain unreachable code
Misra2012 Misra2012:2.1 A project shall not contain unreachable code
Misra2004 Misra2004:14.1 There shall be no unreachable code
AUTOSARC++14 AUTOSARC++14:M0-1-1 A project shall not contain unreachable code.
  AUTOSARC++14:M0-1-2 A project shall not contain infeasible paths.
MisraC++2008 MisraC++2008:0-1-1 A project shall not contain unreachable code.
  MisraC++2008:0-1-2 A project shall not contain infeasible paths.
MisraC++2023 MisraC++2023:0.0.1 A function shall not contain unreachable statements
CWE CWE:561 Dead Code
CERT-C CERT-C:MSC07-C Detect and remove dead code
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
JSF++ JSF++:186 There shall be no unreachable code.
DISA-3r10 DISA-3r10:V-6149 The designer will ensure the application does not contain source code that is never invoked during operation, except for software components and libraries from approved third-party products.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Unreachable Call"
クラス名 Unreachable Computation
日本語クラス名 到達不能な計算
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.UC
カテゴリー
MisraC2023 MisraC2023:2.1 A project shall not contain unreachable code
Misra2012 Misra2012:2.1 A project shall not contain unreachable code
Misra2004 Misra2004:14.1 There shall be no unreachable code
AUTOSARC++14 AUTOSARC++14:M0-1-1 A project shall not contain unreachable code.
  AUTOSARC++14:M0-1-2 A project shall not contain infeasible paths.
MisraC++2008 MisraC++2008:0-1-1 A project shall not contain unreachable code.
  MisraC++2008:0-1-2 A project shall not contain infeasible paths.
CWE CWE:561 Dead Code
CERT-C CERT-C:MSC07-C Detect and remove dead code
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
JSF++ JSF++:186 There shall be no unreachable code.
DISA-3r10 DISA-3r10:V-6149 The designer will ensure the application does not contain source code that is never invoked during operation, except for software components and libraries from approved third-party products.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Unreachable Computation"
クラス名 Unreachable Conditional
日本語クラス名 到達不能な条件
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.UC
カテゴリー
MisraC2023 MisraC2023:2.1 A project shall not contain unreachable code
Misra2012 Misra2012:2.1 A project shall not contain unreachable code
Misra2004 Misra2004:14.1 There shall be no unreachable code
AUTOSARC++14 AUTOSARC++14:M0-1-1 A project shall not contain unreachable code.
  AUTOSARC++14:M0-1-2 A project shall not contain infeasible paths.
MisraC++2008 MisraC++2008:0-1-1 A project shall not contain unreachable code.
  MisraC++2008:0-1-2 A project shall not contain infeasible paths.
CWE CWE:561 Dead Code
CERT-C CERT-C:MSC07-C Detect and remove dead code
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
JSF++ JSF++:186 There shall be no unreachable code.
DISA-3r10 DISA-3r10:V-6149 The designer will ensure the application does not contain source code that is never invoked during operation, except for software components and libraries from approved third-party products.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Unreachable Conditional"
クラス名 Unreachable Control Flow
日本語クラス名 到達不能なコントロールフロー
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.UC
カテゴリー
MisraC2023 MisraC2023:2.1 A project shall not contain unreachable code
Misra2012 Misra2012:2.1 A project shall not contain unreachable code
Misra2004 Misra2004:14.1 There shall be no unreachable code
AUTOSARC++14 AUTOSARC++14:M0-1-1 A project shall not contain unreachable code.
  AUTOSARC++14:M0-1-2 A project shall not contain infeasible paths.
MisraC++2008 MisraC++2008:0-1-1 A project shall not contain unreachable code.
  MisraC++2008:0-1-2 A project shall not contain infeasible paths.
CWE CWE:561 Dead Code
CERT-C CERT-C:MSC07-C Detect and remove dead code
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
JSF++ JSF++:186 There shall be no unreachable code.
DISA-3r10 DISA-3r10:V-6149 The designer will ensure the application does not contain source code that is never invoked during operation, except for software components and libraries from approved third-party products.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっています。チェックを有効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += allow class="Unreachable Control Flow"
クラス名 Unreachable Data Flow
日本語クラス名 到達不能なデータフロー
クラス分類 冗長性 (redundancy)
ニーモニック LANG.STRUCT.UC
カテゴリー
MisraC2023 MisraC2023:2.1 A project shall not contain unreachable code
Misra2012 Misra2012:2.1 A project shall not contain unreachable code
Misra2004 Misra2004:14.1 There shall be no unreachable code
AUTOSARC++14 AUTOSARC++14:M0-1-1 A project shall not contain unreachable code.
  AUTOSARC++14:M0-1-2 A project shall not contain infeasible paths.
MisraC++2008 MisraC++2008:0-1-1 A project shall not contain unreachable code.
  MisraC++2008:0-1-2 A project shall not contain infeasible paths.
CWE CWE:561 Dead Code
CERT-C CERT-C:MSC07-C Detect and remove dead code
  CERT-C:MSC12-C Detect and remove code that has no effect or is never executed
JSF++ JSF++:186 There shall be no unreachable code.
DISA-3r10 DISA-3r10:V-6149 The designer will ensure the application does not contain source code that is never invoked during operation, except for software components and libraries from approved third-party products.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Unreachable Data Flow"

#include <stdlib.h>
#include <stddef.h>

void g(void);

int f(int i){
    if( i ) exit( i );
    return 0;
}

/* For unreachable_computation(), unreachable_conditional(),
 * unreachable_conditional(), and unreachable_data_flow(), the first
 * statement in the function body is
 *    int rv = f(5);
 *
 * The call to f() is reachable but never returns, so the remainder of
 * the function, including the assignment of the return value to rv
 * that takes place in the same statement, is unreachable. (This
 * assignment is itself a data flow.) The warning class for each of
 * these cases will depend on the nature of the statements in the
 * unreachable block.
 */
int unreachable_call(int x){
    int p;
    int rv = f(5); /* 'Unreachable Call' warning issued here */
    g();                       /* call (highest severity) */
    rv += x;                   /* computation */
    if (x>5) {                 /* conditional */ 
      return 0;                /* data flow */
    }
    p = rv;                    /* data flow */
    return p;
}

int unreachable_computation(int x){
    int p;
    int rv = f(5); /* 'Unreachable Computation' warning issued here */
    rv += x;                   /* computation (highest severity) */   
    if (x>5) {                 /* conditional */ 
      return 0;                /* data flow */
    }
    p = rv;                    /* data flow */
    return p;
}

int unreachable_conditional(int x){
    int p;
    int rv = f(5); /* 'Unreachable Conditional' warning issued here */ 
    if (x>5) {                 /* conditional (highest severity) */ 
      return 0;                /* data flow */
    }
    p = rv;                    /* data flow */
    return p;
}

int unreachable_data_flow(){
   int p;
   int rv = f(5);  /* 'Unreachable Data Flow' warning issued here */
   p = rv;                    /* data flow */
   return p;
}


/* In unreachable_control_flow(), a return statement is unreachable
 * because it is in the TRUE branch of an IF statement whose condition
 * always evaluates to FALSE.
 */
void unreachable_control_flow(int x, int y){
    char *q = NULL;
    while (q==NULL){
       q = (char *) malloc(5 * sizeof(char));
    }
    if (q==NULL) {                       /* ('Redundant Condition' warning issued here) */
        return;    /* 'Unreachable Control Flow' warning issued here */
    }
    free(q);
}

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

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