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++


LANG.TYPE.IOT : 不適切なオペランド型

要旨

不適切な型のオペランドを使用しています。

このクラスのワーニングは以下の制約を満たさない場合に検出されます。 この制約は、クリティカルシステム向けのC言語ガイドラインMISRA C:2012実質的な型および 複合式に記載されている概念に基づいています。

演算子 オペランド 適切な実質的な型
[] index essentially enum, essentially signed, or essentially unsigned
unary + only essentially signed, essentially unsigned, essentially real floating, or essentially complex floating
unary - only essentially signed, essentially real floating, or essentially complex floating
binary +, - either essentially character, essentially signed, essentially unsigned, essentially real floating, or essentially complex floating
++, -- only essentially character, essentially signed, essentially unsigned, or essentially real floating
*, / either essentially signed, essentially unsigned, essentially real floating, or essentially complex floating
% either essentially signed or essentially unsigned
<, <=, >=, > either essentially character, essentially enum, essentially signed, essentially unsigned, or essentially real floating
==, != either essentially Boolean, essentially character, essentially enum, essentially signed, essentially unsigned
!, &&, || any essentially Boolean
<<, >> left essentially unsigned
<<, >> right essentially unsigned
~, ^, &, | any essentially unsigned
?: 1st essentially Boolean
?: 2nd, 3rd any essential type

プロパティ

クラス名 Inappropriate Operand Type
日本語クラス名 不適切なオペランド型
クラス分類 スタイル (style)
ニーモニック LANG.TYPE.IOT
カテゴリー
MisraC2025 MisraC2025:10.1 Operands shall not be of an inappropriate essential type
MisraC2023 MisraC2023:10.1 Operands shall not be of an inappropriate essential type
Misra2012 Misra2012:10.1 Operands shall not be of an inappropriate essential type
Misra2004 Misra2004:6.1 The plain char type shall be used only for storage and use of character values
  Misra2004:6.2 signed and unsigned char type shall be used only for the storage and use of numeric values
  Misra2004:12.6 The operands of logical operators (&&, || and !) should be effectively Boolean. Expressions that are effectively Boolean should not be used as operands to operators other than (&&, || , !, =, ==, != and ?:)
  Misra2004:12.7 Bitwise operators shall not be applied to operands whose underlying type is signed
  Misra2004:12.9 The unary minus operator shall not be applied to an expression whose underlying type is unsigned
AUTOSARC++14 AUTOSARC++14:A4-5-1 Expressions with type enum or enum class shall not be used as operands to built-in and overloaded operators other than the subscript operator [ ], the assignment operator =, the equality operators == and ! =, the unary & operator, and the relational operators <, <=, >, >=.
  AUTOSARC++14:M4-5-1 Expressions with type bool shall not be used as operands to built-in operators other than the assignment operator =, the logical operators &&, ||, !, the equality operators == and ! =, the unary & operator, and the conditional operator.
  AUTOSARC++14:M4-5-3 Expressions with type (plain) char and wchar_t shall not be used as operands to built-in operators other than the assignment operator =, the equality operators == and ! =, and the unary & operator.
  AUTOSARC++14:M5-0-11 The plain char type shall only be used for the storage and use of character values.
  AUTOSARC++14:M5-0-12 Signed char and unsigned char type shall only be used for the storage and use of numeric values.
  AUTOSARC++14:M5-0-14 The first operand of a conditional-operator shall have type bool.
  AUTOSARC++14:M5-0-20 Non-constant operands to a binary bitwise operator shall have the same underlying type.
  AUTOSARC++14:M5-0-21 Bitwise operators shall only be applied to operands of unsigned underlying type.
  AUTOSARC++14:M5-3-1 Each operand of the ! operator, the logical && or the logical || operators shall have type bool.
  AUTOSARC++14:M5-3-2 The unary minus operator shall not be applied to an expression whose underlying type is unsigned.
MisraC++2008 MisraC++2008:4-5-1 Expressions with type bool shall not be used as operands to built-in operators other than the assignment operator = , the logical operators && , || , ! , the equality operators == and != , the unary & operator, and the conditional operator.
  MisraC++2008:4-5-2 Expressions with type enum shall not be used as operands to built-in operators other than the subscript operator [ ] , the assignment operator = , the equality operators == and != , the unary & operator, and the relational operators < , <= , > , >= .
  MisraC++2008:4-5-3 Expressions with type (plain) char and wchar_t shall not be used as operands to built-in operators other than the assignment operator = , the equality operators == and != , and the unary & operator.
  MisraC++2008:5-0-11 The plain char type shall only be used for the storage and use of character values.
  MisraC++2008:5-0-12 signed char and unsigned char type shall only be used for the storage and use of numeric values.
  MisraC++2008:5-0-14 The first operand of a conditional-operator shall have type bool.
  MisraC++2008:5-0-20 Non-constant operands to a binary bitwise operator shall have the same underlying type.
  MisraC++2008:5-0-21 Bitwise operators shall only be applied to operands of unsigned underlying type.
  MisraC++2008:5-3-1 Each operand of the ! operator, the logical && or the logical || operators shall have type bool.
  MisraC++2008:5-3-2 The unary minus operator shall not be applied to an expression whose underlying type is unsigned.
MisraC++2023 MisraC++2023:7.0.3 The numerical value of a character shall not be used
  MisraC++2023:7.0.4 The operands of bitwise operators and shift operators shall be appropriate
  MisraC++2023:8.3.1 The built-in unary - operator should not be applied to an expression of unsigned type
CERT-C CERT-C:EXP46-C Do not use a bitwise operator with a Boolean-like operand
  CERT-C:INT07-C Use only explicitly signed or unsigned char type for numeric values
  CERT-C:INT13-C Use bitwise operators only on unsigned operands
  CERT-C:STR04-C Use plain char for characters in the basic character set
JSF++ JSF++:164.1 The left-hand operand of a right-shift operator shall not have a negative value.
  JSF++:165 The unary minus operator shall not be applied to an unsigned expression.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっており、プロジェクトには非正規の C向けAST が必要になります。有効にするにはプロジェクト設定ファイル (configuration file) に以下の WARNING_FILTER ルールと RETAIN_UNNORMALIZED_C_AST 設定を追加してください。
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Inappropriate Operand Type"
注:非正規化された AST を継続して使用した場合、使用ディスク容量が増加し解析時間が長くなる可能性があります。

int TYPE_IOT(int arr[10], int i){
    int x;

    if (i >= 10 || i < 0)                  /* suitable operand types for >=, <, || */ 
        return i;

    x = arr[i];                            /* suitable operand type for [] */
    if (x<0){return x;}
    x = arr[i==5];   /* 'Inappropriate Operand Type' warning issued here */
    if (x<0){return x;}
    x = i * 'a';     /* 'Inappropriate Operand Type' warning issued here */
    return x;
}

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

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

 

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