MISRA C:2023 Rule 21.15
The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types
R2024a 以降
説明
ルール定義
The pointer arguments to the Standard Library functions memcpy, memmove and memcmp shall be pointers to qualified or unqualified versions of compatible types. 1
This rule comes from MISRA C™:2012 Amendment 1.
根拠
以下の関数
memcpy( arg1, arg2, num_bytes ); memmove( arg1, arg2, num_bytes ); memcmp( arg1, arg2, num_bytes );
arg1 と arg2 が指すメモリの場所の間でバイト単位のコピー、移動または比較を実行します。arg1 と arg2 の型に互換性がある場合のみ、バイト単位のコピー、移動または比較が意味を持ちます。arg1 と arg2 に異なるデータ型へのポインターを使用すると通常コーディング エラーが示されます。
トラブルシューティング
ルール違反を想定していてもその違反が表示されない場合、コーディング規約違反が想定どおりに表示されない理由の診断を参照します。
例
チェック情報
| グループ: 標準ライブラリ |
| カテゴリ: 必要 |
| AGC カテゴリ: 必要 |
バージョン履歴
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.