メインコンテンツ

このページの内容は最新ではありません。最新版の英語を参照するには、ここをクリックします。

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.1Operands shall not be of an inappropriate essential type.&&||! などの論理オペランドとポインター型を使用することは、このルールで明確に禁止されるようになりました。
MISRA C:2012 Rule 10.5The value of an expression should not be cast to an inappropriate essential type.値 0 または 1 の整数定数から実質的な enum 型へのキャストが、このルールで禁止されるようになりました。
MISRA C:2012 Rule 11.2Conversions shall not be performed between a pointer to an incomplete type and any other type.このルールで、ポインターが指す非修飾型のみが考慮されるようになりました。たとえば、ポインターが別のポインターに割り当てられる場合に、ポインターが指す型の唯一の違いが const 修飾子である場合、このルールではこの割り当てが変換とは見なされません。
MISRA C:2012 Rule 11.4A conversion should not be performed between a pointer to object and an integer type.このルールは、オブジェクトへのポインターのみに明示的に適用されるようになりました。整数型と、void* などのその他のポインター型または関数へのポインターとの間の変換には、別のルールによってフラグが設定されます。
MISRA C:2012 Rule 11.9The macro NULL shall be the only permitted form of integer null pointer constant.このルールでは、ポインターを含む集合体または共用体の初期化に {0} を使用することが許可されます。
MISRA C:2012 Rule 14.2A 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.5A project should not contain unused macro definitionsルールのタイトルが変更されました。単語 'declarations' が 'definitions' に置き換えられました。
MISRA C:2012 Rule 10.2Expressions of essentially character type shall not be used inappropriately in addition and subtraction operationsPolyspace は、char 型の変数を使用する算術演算で long または long long 型の変数が使用されている場合に、このルールの違反を報告するようになりました。
MISRA C:2012 Rule 13.6The operand of the sizeof operator shall not contain any expression which has potential side effectsR2023b 以降、このルールは "必須" ではなく "必要" です。
MISRA C:2012 Rule 17.4All exit paths from a function with non-void return type shall have an explicit return statement with an expressionR2023b 以降、C99 以降の C コードの main() 関数に明示的な return ステートメントがない場合、Polyspace は違反を報告しません。
MISRA C:2012 Rule 17.5The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elementsR2023b 以降、このルールは "推奨" ではなく "必要" です。

MISRA C:2012 Amendment 1 (AMD1)

MISRA C:2012 Amendment 1 では、セキュリティの脆弱性を防ぐ新しいコーディング ルールが導入されました。

ルール説明
MISRA C:2012 Dir 4.14The validity of values received from external sources shall be checked.
MISRA C:2012 Rule 12.5The sizeof operator shall not have an operand which is a function parameter declared as "array of type".
MISRA C:2012 Rule 21.13Any 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.14The Standard Library function memcmp shall not be used to compare null terminated strings.
MISRA C:2012 Rule 21.15The 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.16The 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.17Use 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.18The size_t argument passed to any function in <string.h> shall have an appropriate value.
MISRA C:2012 Rule 21.19The 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.20The 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.7The 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.8The value of errno shall be set to zero prior to a call to an errno-setting-function.
MISRA C:2012 Rule 22.9The value of errno shall be tested against zero after calling an errno-setting function.
MISRA C:2012 Rule 22.10The 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.8The Standard Library termination functions of <stdlib.h> shall not be used

getenv への参照がルール ヘッドラインと補足から削除されました。

21.19 と 21.20 の導入後、21.8 での getenv の使用は不要になりました。

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.4Emergent language features shall not be used.これは Amendment 2 の新しいルールです。
MISRA C:2012 Rule 12.1The precedence of operators within expressions should be made explicit.このルールでは、_Alignof 演算子のオペランドがかっこで囲まれていない場合に違反とすることが義務付けられるようになりました。
MISRA C:2012 Rule 21.3The memory allocation and deallocation functions of <stdlib.h> shall not be used.このルールでは、関数 aligned_alloc の使用にフラグが設定されるようになりました。
MISRA C:2012 Rule 21.8The Standard Library termination functions of <stdlib.h> shall not be used.

このルールでは system にフラグが設定されなくなりました。

このルールでは、exitabort の他に、_Exitquick_exit にフラグが設定されるようになりました。

MISRA C:2012 Rule 21.21The Standard Library function system of <stdlib.h> shall not be used.これは Amendment 2 の新しいルールです。
MISRA C:2012 Rule 22.1All 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.15Evaluation of floating-point expressions shall not lead to the undetected generation of infinities and NaNs.
MISRA C:2012 Rule 1.5Obsolescent language features shall not be used.
MISRA C:2012 Rule 6.3A bit field shall not be declared as a member of a union.
MISRA C:2012 Rule 7.5The argument of an integer constant macro shall have an appropriate form.
MISRA C:2012 Rule 8.15All declarations of an object with an explicit alignment specification shall specify the same alignment.
MISRA C:2012 Rule 8.16The alignment specification of zero should not appear in an object declaration.
MISRA C:2012 Rule 8.17At most one explicit alignment specifier should appear in an object declaration.
MISRA C:2012 Rule 17.9A function declared with a _Noreturn function specifier shall not return to its caller.
MISRA C:2012 Rule 17.10A function declared with a _Noreturn function specifier shall have void return type.
MISRA C:2012 Rule 17.11A function that never returns should be declared with a _Noreturn function specifier.
MISRA C:2012 Rule 17.12A function identifier should only be used with either a preceding &, or with a parenthesized parameter list.
MISRA C:2012 Rule 17.13A function type shall not be type qualified.
MISRA C:2012 Rule 18.9An object with temporary lifetime shall not undergo array-to-pointer conversion.
MISRA C:2012 Rule 21.22All operand arguments to any type-generic macros declared in <tgmath.h> shall have an appropriate essential type.
MISRA C:2012 Rule 21.23All operand arguments to any multi-argument type-generic macros declared in <tgmath.h> shall have the same standard type.
MISRA C:2012 Rule 21.24The random number generator functions of <stdlib.h> shall not be used.
MISRA C:2012 Rule 23.1A generic selection should only be expanded from a macro.
MISRA C:2012 Rule 23.2A generic selection that is not expanded from a macro shall not contain potential side effects in the controlling expression.
MISRA C:2012 Rule 23.3A generic selection should contain at least one non-default association.
MISRA C:2012 Rule 23.4A generic association shall list an appropriate type.
MISRA C:2012 Rule 23.5A generic selection should not depend on implicit pointer type conversion.
MISRA C:2012 Rule 23.6The controlling expression of a generic selection shall have an essential type that matches its standard type.
MISRA C:2012 Rule 23.7A generic selection that is expanded from a macro should evaluate its argument only once.
MISRA C:2012 Rule 23.8A 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.6Polyspace は、実質的な複素数の浮動小数点型の typedefs でサイズと符号属性が示されない場合に、違反を報告します。
MISRA C:2012 Dir 4.9この命令では、総称選択に使用される関数形式のマクロが許可されるようになりました。
MISRA C:2012 Dir 4.11範囲 [-π,π] の外部の値を使用して math.h の周期的な三角関数が呼び出される場合、Polyspace は違反を報告します。
MISRA C:2012 Rule 1.4

このルールでは次の機能の使用が許可されるようになりました。

  • _Generic 演算子

  • _Noreturn 指定子

  • <stdnoreturn.h> ヘッダー ファイル

  • _Alignas アライメント指定子

  • _Alignof 演算子

  • <stdalign.h> ヘッダー ファイル

MISRA C:2012 Rule 10.1Polyspace は、実数の浮動小数点型と複素数の浮動小数点型の比較に対して違反を報告します。
MISRA C:2012 Rule 10.3Polyspace は、実質的な実数の浮動小数点型から実質的な複素数の浮動小数点型への適切な代入に対して違反を報告しません。
MISRA C:2012 Rule 10.4このルールでは実質的な複素型がサポートされるようになりました。
MISRA C:2012 Rule 10.5Polyspace は、実質的な複素数の浮動小数点型への不適切な変換、および実質的な複素数の浮動小数点型からの不適切な変換に対して違反を報告します。
MISRA C:2012 Rule 10.7このルールでは実質的な複素型がサポートされるようになりました。
MISRA C:2012 Rule 10.8Polyspace は、複素数がより範囲の広い実質的な型にキャストされるか、またはより範囲の狭い実質的な型からキャストされる場合に違反を報告します。
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.1There shall be no data races between threads.
MISRA C:2012 Dir 5.2There shall be no deadlocks between threads.
MISRA C:2012 Rule 2.8A project should not contain unused object definitions
MISRA C:2012 Rule 7.6The small integer variants of the minimum-width integer constant macros shall not be used
MISRA C:2012 Rule 9.6An initializer using chained designators shall not contain initializers without designators
MISRA C:2012 Rule 11.10The _Atomic qualifier shall not be applied to the incomplete type void
MISRA C:2012 Rule 12.6Structure and union members of atomic objects shall not be directly accessed
MISRA C:2012 Rule 18.10Pointers to variably-modified array types shall not be used
MISRA C:2012 Rule 21.25All memory synchronization operations shall be executed in sequentially consistent order
MISRA C:2012 Rule 22.11A thread that was previously either joined or detached shall not be subsequently joined nor detached.
MISRA C:2012 Rule 22.13Thread objects, thread synchronization objects and thread-specific storage pointers shall have appropriate storage duration
MISRA C:2012 Rule 22.15Thread synchronization objects and thread-specific storage pointers shall not be destroyed until after all threads accessing them have terminated.
MISRA C:2012 Rule 22.16All mutex objects locked by a thread shall be explicitly unlocked by the same thread.
MISRA C:2012 Rule 22.17No 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.18Non-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" に変更されました。