このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。
MISRA C:2012 Technical Corrigenda and Amendments に対する Polyspace のサポート
R2021a 以降、Polyspace® Bug Finder™ は Technical Corrigendum 1、Technical Corrigendum 2、Amendment 1、Amendment 2、および Amendment 3 における MISRA C™:2012 ルールの改正をサポートしています。
MISRA C:2012 Technical Corrigendum 1
MISRA C:2012 Technical Corrigendum 1 により、既存のルールがより明確になりました。この明確化に伴い、Polyspace チェッカーにおいて対応する変更が行われました。
| ルール | 説明 | Technical Corrigendum 1 での更新内容 |
|---|---|---|
MISRA C:2012 Rule 10.1 | Operands shall not be of an inappropriate essential type. | &&、||、! などの論理オペランドとポインター型を使用することは、このルールで明確に禁止されるようになりました。 |
MISRA C:2012 Rule 10.5 | The value of an expression should not be cast to an inappropriate essential type. | 値 0 または 1 の整数定数から実質的な enum 型へのキャストが、このルールで禁止されるようになりました。 |
MISRA C:2012 Rule 11.2 | Conversions shall not be performed between a pointer to an incomplete type and any other type. | このルールで、ポインターが指す非修飾型のみが考慮されるようになりました。たとえば、ポインターが別のポインターに割り当てられる場合に、ポインターが指す型の唯一の違いが const 修飾子である場合、このルールではこの割り当てが変換とは見なされません。 |
MISRA C:2012 Rule 11.4 | A conversion should not be performed between a pointer to object and an integer type. | このルールは、オブジェクトへのポインターのみに明示的に適用されるようになりました。整数型と、void* などのその他のポインター型または関数へのポインターとの間の変換には、別のルールによってフラグが設定されます。 |
MISRA C:2012 Rule 11.9 | The macro NULL shall be the only permitted form of integer null pointer constant. | このルールでは、ポインターを含む集合体または共用体の初期化に {0} を使用することが許可されます。 |
MISRA C:2012 Rule 14.2 | A for loop shall be well-formed. | このルールでは、初期化に他の二次的影響がない限り、あらゆる形式でのループ カウンターの初期化が許可されます。 |
MISRA C:2012 Technical Corrigendum 2
MISRA C:2012 Technical Corrigendum 2 により、既存のルールがより明確になりました。この明確化に伴い、これらの Polyspace チェッカーにおいて対応する変更が行われました。
| ルール | 説明 | Technical Corrigendum 2 での更新内容 |
|---|---|---|
MISRA C:2012 Rule 2.5 | A project should not contain unused macro definitions | ルールのタイトルが変更されました。単語 'declarations' が 'definitions' に置き換えられました。 |
MISRA C:2012 Rule 10.2 | Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations | Polyspace は、char 型の変数を使用する算術演算で long または long long 型の変数が使用されている場合に、このルールの違反を報告するようになりました。 |
MISRA C:2012 Rule 13.6 | The operand of the sizeof operator shall not contain any expression which has potential side effects | R2023b 以降、このルールは "必須" ではなく "必要" です。 |
MISRA C:2012 Rule 17.4 | All exit paths from a function with non-void return type shall have an explicit return statement with an expression | R2023b 以降、C99 以降の C コードの main() 関数に明示的な return ステートメントがない場合、Polyspace は違反を報告しません。 |
MISRA C:2012 Rule 17.5 | The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements | R2023b 以降、このルールは "推奨" ではなく "必要" です。 |
MISRA C:2012 Amendment 1 (AMD1)
MISRA C:2012 Amendment 1 では、セキュリティの脆弱性を防ぐ新しいコーディング ルールが導入されました。
| ルール | 説明 |
|---|---|
MISRA C:2012 Dir 4.14 | The validity of values received from external sources shall be checked. |
MISRA C:2012 Rule 12.5 | The sizeof operator shall not have an operand which is a function parameter declared as "array of type". |
MISRA C:2012 Rule 21.13 | Any value passed to a function in <ctype.h> shall be representable as an unsigned char or be the value EOF. |
MISRA C:2012 Rule 21.14 | The Standard Library function memcmp shall not be used to compare null terminated strings. |
MISRA C:2012 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. |
MISRA C:2012 Rule 21.16 | The pointer arguments to the Standard Library function memcmp shall point to either a pointer type, an essentially signed type, an essentially unsigned type, an essentially Boolean type or an essentially enum type. |
MISRA C:2012 Rule 21.17 | Use of the string handling function from <string.h> shall not result in accesses beyond the bounds of the objects referenced by their pointer parameters. |
MISRA C:2012 Rule 21.18 | The size_t argument passed to any function in <string.h> shall have an appropriate value. |
MISRA C:2012 Rule 21.19 | The pointers returned by the Standard Library functions localeconv, getenv, setlocale or strerror shall only be used as if they have pointer to const-qualified type. |
MISRA C:2012 Rule 21.20 | The pointer returned by the Standard Library functions asctime, ctime, gmtime, localtime, localeconv, getenv, setlocale or strerror shall not be used following a subsequent call to the same function. |
MISRA C:2012 Rule 22.7 | The macro EOF shall only be compared with the unmodified return value from any Standard Library function capable of returning EOF. |
MISRA C:2012 Rule 22.8 | The value of errno shall be set to zero prior to a call to an errno-setting-function. |
MISRA C:2012 Rule 22.9 | The value of errno shall be tested against zero after calling an errno-setting function. |
MISRA C:2012 Rule 22.10 | The value of errno shall only be tested when the last function to be called was an errno-setting function. |
MISRA C:2012 Amendment 1 では、既存のルールに対する変更が導入されました。
| ルール | 説明 | 変更 |
|---|---|---|
MISRA C:2012 Rule 21.8 | The Standard Library termination functions of <stdlib.h> shall not be used |
21.19 と 21.20 の導入後、21.8 での |
MISRA C:2012 Amendment 2 (AMD2)
MISRA C:2012 Amendment 2 は、ISO®/IEC 9899:2011 (C11) 規格の新しい言語機能に対応しています。Amendment 2 の更新はすべて、Polyspace チェッカーに組み込まれています。
| ルール | 説明 | Amendment 2 の更新 |
|---|---|---|
MISRA C:2012 Rule 1.4 | Emergent language features shall not be used. | これは Amendment 2 の新しいルールです。 |
MISRA C:2012 Rule 12.1 | The precedence of operators within expressions should be made explicit. | このルールでは、_Alignof 演算子のオペランドがかっこで囲まれていない場合に違反とすることが義務付けられるようになりました。 |
MISRA C:2012 Rule 21.3 | The memory allocation and deallocation functions of <stdlib.h> shall not be used. | このルールでは、関数 aligned_alloc の使用にフラグが設定されるようになりました。 |
MISRA C:2012 Rule 21.8 | The Standard Library termination functions of <stdlib.h> shall not be used. | このルールでは このルールでは、 |
MISRA C:2012 Rule 21.21 | The Standard Library function system of <stdlib.h> shall not be used. | これは Amendment 2 の新しいルールです。 |
MISRA C:2012 Rule 22.1 | All resources obtained dynamically by means of Standard Library functions shall be explicitly released. | このルールでは、メモリが解放されていない場合の関数 aligned_alloc を使用したメモリ割り当てにフラグが設定されるようになりました。 |
MISRA C:2012 Amendment 3 (AMD3)
R2024a 以降
MISRA C:2012 Amendment 3 は、ISO/IEC 9899:2011 (C11) 規格および ISO/IEC 9899:2018 (C17/C18) 規格の新しい言語機能に対応しています。
MISRA C:2012 Amendment 3 (AMD3) で導入されたルール
Amendment 3 では、C11 および C18 の言語機能に対応するため、次のルールと命令が追加されました。
| ルール | 説明 |
|---|---|
MISRA C:2012 Dir 4.15 | Evaluation of floating-point expressions shall not lead to the undetected generation of infinities and NaNs. |
MISRA C:2012 Rule 1.5 | Obsolescent language features shall not be used. |
MISRA C:2012 Rule 6.3 | A bit field shall not be declared as a member of a union. |
MISRA C:2012 Rule 7.5 | The argument of an integer constant macro shall have an appropriate form. |
MISRA C:2012 Rule 8.15 | All declarations of an object with an explicit alignment specification shall specify the same alignment. |
MISRA C:2012 Rule 8.16 | The alignment specification of zero should not appear in an object declaration. |
MISRA C:2012 Rule 8.17 | At most one explicit alignment specifier should appear in an object declaration. |
MISRA C:2012 Rule 17.9 | A function declared with a _Noreturn function specifier shall not return to its caller. |
MISRA C:2012 Rule 17.10 | A function declared with a _Noreturn function specifier shall have void return type. |
MISRA C:2012 Rule 17.11 | A function that never returns should be declared with a _Noreturn function specifier. |
MISRA C:2012 Rule 17.12 | A function identifier should only be used with either a preceding &, or with a parenthesized parameter list. |
MISRA C:2012 Rule 17.13 | A function type shall not be type qualified. |
MISRA C:2012 Rule 18.9 | An object with temporary lifetime shall not undergo array-to-pointer conversion. |
MISRA C:2012 Rule 21.22 | All operand arguments to any type-generic macros declared in <tgmath.h> shall have an appropriate essential type. |
MISRA C:2012 Rule 21.23 | All operand arguments to any multi-argument type-generic macros declared in <tgmath.h> shall have the same standard type. |
MISRA C:2012 Rule 21.24 | The random number generator functions of <stdlib.h> shall not be used. |
MISRA C:2012 Rule 23.1 | A generic selection should only be expanded from a macro. |
MISRA C:2012 Rule 23.2 | A generic selection that is not expanded from a macro shall not contain potential side effects in the controlling expression. |
MISRA C:2012 Rule 23.3 | A generic selection should contain at least one non-default association. |
MISRA C:2012 Rule 23.4 | A generic association shall list an appropriate type. |
MISRA C:2012 Rule 23.5 | A generic selection should not depend on implicit pointer type conversion. |
MISRA C:2012 Rule 23.6 | The controlling expression of a generic selection shall have an essential type that matches its standard type. |
MISRA C:2012 Rule 23.7 | A generic selection that is expanded from a macro should evaluate its argument only once. |
MISRA C:2012 Rule 23.8 | A default association shall appear as either the first or the last association of a generic selection. |
MISRA C:2012 Amendment 3 (AMD3) で変更されたルール
Amendment 3 では、C11 および C18 の機能に対応するため、次の既存ルールと命令が変更されました。
| ルール | 変更の目的 |
|---|---|
MISRA C:2012 Dir 4.6 | Polyspace は、実質的な複素数の浮動小数点型の typedefs でサイズと符号属性が示されない場合に、違反を報告します。 |
MISRA C:2012 Dir 4.9 | この命令では、総称選択に使用される関数形式のマクロが許可されるようになりました。 |
MISRA C:2012 Dir 4.11 | 範囲 [-π,π] の外部の値を使用して math.h の周期的な三角関数が呼び出される場合、Polyspace は違反を報告します。 |
MISRA C:2012 Rule 1.4 | このルールでは次の機能の使用が許可されるようになりました。
|
MISRA C:2012 Rule 10.1 | Polyspace は、実数の浮動小数点型と複素数の浮動小数点型の比較に対して違反を報告します。 |
MISRA C:2012 Rule 10.3 | Polyspace は、実質的な実数の浮動小数点型から実質的な複素数の浮動小数点型への適切な代入に対して違反を報告しません。 |
MISRA C:2012 Rule 10.4 | このルールでは実質的な複素型がサポートされるようになりました。 |
MISRA C:2012 Rule 10.5 | Polyspace は、実質的な複素数の浮動小数点型への不適切な変換、および実質的な複素数の浮動小数点型からの不適切な変換に対して違反を報告します。 |
MISRA C:2012 Rule 10.7 | このルールでは実質的な複素型がサポートされるようになりました。 |
MISRA C:2012 Rule 10.8 | Polyspace は、複素数がより範囲の広い実質的な型にキャストされるか、またはより範囲の狭い実質的な型からキャストされる場合に違反を報告します。 |
MISRA C:2012 Rule 11.7 | このルールでは実質的な複素型がサポートされるようになりました。 |
MISRA C:2012 Rule 21.11 | このルールは "推奨" として分類されるようになりました。 |
MISRA C:2012 Rule 21.12 | このルールは "必要" として分類されるようになりました。 |
MISRA C:2012 Amendment 4 (AMD4)
MISRA C:2012 Amendment 4 は、ISO/IEC 9899:2011 (C11) 規格および ISO/IEC 9899:2018 (C17/C18) 規格の同時実行機能に対応しています。
MISRA C:2012 Amendment 4 (AMD4) で導入されたルール
Polyspace は Amendment 4 の次のルールをサポートしています。
| ルールまたは命令 | 説明 |
|---|---|
MISRA C:2012 Dir 5.1 | There shall be no data races between threads. |
MISRA C:2012 Dir 5.2 | There shall be no deadlocks between threads. |
MISRA C:2012 Rule 2.8 | A project should not contain unused object definitions |
MISRA C:2012 Rule 7.6 | The small integer variants of the minimum-width integer constant macros shall not be used |
MISRA C:2012 Rule 9.6 | An initializer using chained designators shall not contain initializers without designators |
MISRA C:2012 Rule 11.10 | The _Atomic qualifier shall not be applied to the incomplete type void |
MISRA C:2012 Rule 12.6 | Structure and union members of atomic objects shall not be directly accessed |
MISRA C:2012 Rule 18.10 | Pointers to variably-modified array types shall not be used |
MISRA C:2012 Rule 21.25 | All memory synchronization operations shall be executed in sequentially consistent order |
MISRA C:2012 Rule 22.11 | A thread that was previously either joined or detached shall not be subsequently joined nor detached. |
MISRA C:2012 Rule 22.13 | Thread objects, thread synchronization objects and thread-specific storage pointers shall have appropriate storage duration |
MISRA C:2012 Rule 22.15 | Thread synchronization objects and thread-specific storage pointers shall not be destroyed until after all threads accessing them have terminated. |
MISRA C:2012 Rule 22.16 | All mutex objects locked by a thread shall be explicitly unlocked by the same thread. |
MISRA C:2012 Rule 22.17 | No thread shall unlock a mutex or call cnd_wait() or cnd_timedwait() for a mutex it has not locked before. |
MISRA C:2012 Rule 22.18 | Non-recursive mutexes shall not be recursively locked |
MISRA C:2012 Amendment 4 (AMD4) で変更されたルール
Amendment 4 では、次の既存ルールと命令が変更されました。
| ルールまたは命令 | 変更の説明 |
|---|---|
MISRA C:2012 Rule 2.2 | ルール定義が "A project shall not contain dead code" に変更されました。 |
MISRA C:2012 Rule 2.7 | ルール定義が "A function should not contain unused parameters" に変更されました。 |
MISRA C:2012 Rule 8.9 | ルール定義が "An object should be declared at block scope if its identifier only appears in a single function" に変更されました。 |
MISRA C:2012 Rule 11.3 | ルール定義が "A conversion shall not be performed between a pointer to object type and a pointer to a different object type" に変更されました。 |
MISRA C:2012 Rule 11.8 | _Atomic 修飾に対応するようにルールが拡張されました。ルール定義が "A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer" に変更されました。 |
MISRA C:2012 Rule 13.2 | このルールは、同時実行性に対応するように拡張されました。ルール定義が "The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders and shall be independent from thread interleaving" に変更されました。 |
MISRA C:2012 Rule 18.3 | このルールはポインター型のオブジェクトではなくポインター型の式に適用されるようになりました。ルール定義が "The relational operators >, >=, < and <= shall not be applied to expressions of pointer type except where they point into the same object" に変更されました。 |
MISRA C:2012 Rule 18.6 | このルールは、スレッド ローカル オブジェクトに対応するように拡張されました。ルール定義が "The address of an object with automatic or thread-local storage shall not be copied to another object that persists after the first object has ceased to exist" に変更されました。 |
MISRA C:2012 Rule 18.8 | このルールは可変長の配列のみに限定されます。ルール定義が "Variable-length arrays shall not be used" に変更されました。 |