AUTOSAR C++14 Rule M5-0-8
An explicit integral or floating-point conversion shall not increase the size of the underlying type of a cvalue expression.
説明
ルール定義
An explicit integral or floating-point conversion shall not increase the size of the underlying type of a cvalue expression.
根拠
式を評価し、後でその結果を別の型にキャストする場合、そのキャストは評価の潜在型には影響しません。たとえば、この例では 2 つの short 型のオペランドの合計がより大きな int 型にキャストされます。
short op1; short op2; int res; res= static_cast<int> (op1 + op2);
int を使用した合計であると見なされることがあります。トラブルシューティング
ルール違反が想定されるものの、Polyspace® から報告されない場合は、コーディング規約違反が想定どおりに表示されない理由の診断を参照してください。
例
チェック情報
| グループ: 式 |
| カテゴリ: Required、Automated |
バージョン履歴
R2019a で導入