JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.

If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.

If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.

CodeSonar® 9.2p0 CONFIDENTIAL CodeSecure Inc
C and C++
Binaries


LANG.ARITH.BIGSHIFT : ビット幅を超えるシフト

要旨

data << shift_amount

または

data >> shift_amount

にて、shift_amount によるシフト結果はデータ型の範囲外となります。

プロパティ

クラス名 Shift Amount Exceeds Bit Width
日本語クラス名 ビット幅を超えるシフト
クラス分類 セキュリティ (security)
ニーモニック LANG.ARITH.BIGSHIFT
カテゴリー
MisraC2025 MisraC2025:1.3 There shall be no occurrence of undefined or critical unspecified behaviour
  MisraC2025:12.2 The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand
MisraC2023 MisraC2023:1.3 There shall be no occurrence of undefined or critical unspecified behaviour
  MisraC2023:12.2 The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand
Misra2012 Misra2012:1.3 There shall be no occurrence of undefined or critical unspecified behaviour
  Misra2012:12.2 The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand
Misra2004 Misra2004:12.8 The right-hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left-hand operand
AUTOSARC++14 AUTOSARC++14:M5-8-1 The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left hand operand.
MisraC++2008 MisraC++2008:5-8-1 The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left hand operand.
MisraC++2023 MisraC++2023:0.3.2 A function call shall not violate the function's preconditions
  MisraC++2023:4.1.3 There shall be no occurrence of undefined or critical unspecified behaviour
  MisraC++2023:7.0.4 The operands of bitwise operators and shift operators shall be appropriate
CWE CWE:758 Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
  CWE:1335 Incorrect Bitwise Shift of Integer
CERT-C CERT-C:INT34-C Do not shift an expression by a negative number of bits or by greater than or equal to the number of bits that exist in the operand
  CERT-C:INT35-C Use correct integer precisions
JSF++ JSF++:164 The right hand operand of a shift operator shall lie between zero and one less than the width in bits of the left-hand operand (inclusive).
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで有効になっています。チェックを無効にするにはプロジェクト設定ファイル (configuration file)に以下の WARNING_FILTER ルールを追加してください。
WARNING_FILTER += discard class="Shift Amount Exceeds Bit Width"

int do_bigshift(void){
    int a = 50;
    int b = a << 200;   /* 'Shift Amount Exceeds Bit Width' warning issued here */
    return a+b;
}

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

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

 

To report problems with this documentation, please visit https://support.codesecure.com/.