MISRA C++:2008 Rule 5-0-9
An explicit integral conversion shall not change the signedness of the underlying type of a cvalue expression.
説明
ルール定義
An explicit integral conversion shall not change the signedness of the underlying type of a cvalue expression. 1
根拠
このチェッカーによってフラグが設定される式は、MISRA™ C++ ドキュメンテーションの cvalue 式の詳細仕様に従います。
式を評価し、後でその結果を別の型にキャストする場合、そのキャストは評価の潜在型 (式にあるオペランドのデータ型のうち範囲が最も広いもの) には影響しません。たとえば、この例では 2 つの unsigned int 型のオペランドの合計が int 型にキャストされます。
unsigned int op1; unsigned int op2; int res; res= static_cast<int> (op1 + op2);
int を使用した合計であると見なされることがあります。トラブルシューティング
ルール違反が想定されるものの、Polyspace® から報告されない場合は、コーディング規約違反が想定どおりに表示されない理由の診断を参照してください。
例
チェック情報
| グループ: Expressions |
| カテゴリ: 必要 |
バージョン履歴
R2013b で導入1 All MISRA coding rules and directives are © Copyright The MISRA Consortium Limited 2021.
The MISRA coding standards referenced in the Polyspace Bug Finder™ documentation are from the following MISRA standards:
MISRA C:2004
MISRA C:2012
MISRA C:2023
MISRA C++:2008
MISRA C++:2023
MISRA and MISRA C are registered trademarks of The MISRA Consortium Limited 2021.