C and C++


LANG.TYPE.OC : 8進定数の使用

要旨

0 以外の)整数定数が8進のフォーマットで定義されています。

プロパティ

クラス名 Octal Constant
日本語クラス名 8進定数の使用
クラス分類 スタイル (style)
ニーモニック LANG.TYPE.OC
カテゴリー
MisraC2023 MisraC2023:7.1 Octal constants shall not be used
Misra2012 Misra2012:7.1 Octal constants shall not be used
Misra2004 Misra2004:7.1 Octal constants (other than zero) and octal escape sequences shall not be used
AUTOSARC++14 AUTOSARC++14:M2-13-2 Octal constants (other than zero) and octal escape sequences (other than "\0" ) shall not be used.
MisraC++2008 MisraC++2008:2-13-2 Octal constants (other than zero) and octal escape sequences (other than "\0") shall not be used.
MisraC++2023 MisraC++2023:5.13.3 Octal constants shall not be used
CWE CWE:1078 Inappropriate Source Code Style or Formatting
  CWE:1389 Incorrect Parsing of Numbers with Different Radices
CERT-C CERT-C:DCL18-C Do not begin integer constants with 0 when specifying a decimal value
JSF++ JSF++:149 Octal constants (other than zero) shall not be used.
対応言語 C および C++ で利用可能です。
有効/無効設定 このワーニングクラスのチェックはデフォルトで無効になっており、プロジェクトには非正規の C向けAST が必要になります。有効にするにはプロジェクト設定ファイル (configuration file) に以下の WARNING_FILTER ルールと RETAIN_UNNORMALIZED_C_AST 設定を追加してください。
RETAIN_UNNORMALIZED_C_AST = Yes
WARNING_FILTER += allow class="Octal Constant"
注:非正規化された AST を継続して使用した場合、使用ディスク容量が増加し解析時間が長くなる可能性があります。

int decint = 10;                              /* decimal format */

int octint = 012; /* 'Octal Constant' warning issued here */

int hexint = 0xa;                             /* hexadecimal format */

int octint0 = 0;                              /* 0 is a special case */

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

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