MISRA C++:2023 Rule 7.0.5
Integral promotion and the usual arithmetic conversions shall not change the signedness or the type category of an operand
R2024b 以降
説明
ルール定義
Integral promotion and the usual arithmetic conversions shall not change the signedness or the type category of an operand. 1
根拠
符号付きデータ型から符号なしデータ型への一部の変換、または型カテゴリの変更は、処理系定義の動作につながることがあります。この変換から、予期しない結果がもたらされる可能性があります。
Polyspace 実装
チェッカーは以下にフラグを設定します。
符号付き整数データ型から符号なし整数データ型 (またはその逆) への暗黙的な変換。
チェッカーは、
ptrdiff_t
が符号付き整数であると仮定します。型カテゴリの変更。
ルール チェッカーは MISRA™ C++:2023 仕様に基づいて、型を 4 つのカテゴリに分類します。
文字:
char
、wchar_t
、char16_t
、char32_t
整数:符号付き整数、符号なし整数、スコープのない列挙型 (
signed char
およびunsigned char
を含む)浮動小数点:
float
、double
、long double
その他:
bool
、void
、nullptr_t
トラブルシューティング
ルール違反が想定されるものの、Polyspace® から報告されない場合は、コーディング規約違反が想定どおりに表示されない理由の診断を参照してください。
例
チェック情報
グループ: Standard Conversions |
カテゴリ: Required |
バージョン履歴
R2024b で導入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.