MISRA C:2023 Rule 13.3
A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator
R2024a 以降
説明
ルール定義
A full expression containing an increment (++) or decrement (--) operator should have no other potential side effects other than that caused by the increment or decrement operator 1 .
根拠
同一コード行で以下が発生する場合、ルールに違反します。
インクリメント演算子またはデクリメント演算子が変数に作用する。
別の読み取りまたは書き込み操作が変数に対して実行される。
たとえば、行 y=x++ はこのルールに違反しています。++ 演算子および = 演算子の両方が x に作用しています。
演算子の優先順位ルールは評価順序を決定しますが、++ と別の演算子を同じ行に置くとコードの可読性が低下します。
トラブルシューティング
ルール違反を想定していてもその違反が表示されない場合、コーディング規約違反が想定どおりに表示されない理由の診断を参照します。
例
チェック情報
| グループ: 二次的影響 |
| カテゴリ: 推奨 |
| AGC カテゴリ: Readability |
バージョン履歴
R2024a で導入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.