MISRA C:2004 Compliance Matrix

In this section you will find a description of all MISRA (The Motor Industry Software Reliability Association) rules. Due to copyright limitations, we have altered rule descriptions. The original descriptions can be found in Guidelines for The Use of The C Language in Vehicle Based Software, October 2004, The Motor Industry Software Reliability Association, Watling Street, Nuneaton, Warwickshire CV10 OTU, www.misra.org.uk

Rules are classified by MISRA as either required Re or advisory Ad. The succeeding sections list all rules along with support notes: whether the rule is fully supported (those rules are marked MISRA C Supported Icon Re/Ad, or either not statically checkable or not supported in DA-C MISRA C Non Supported Icon Re-/Ad-. Current list of unsupported rules can also be viewed in the "Options > Static Code Analyzer".

Environment

MISRA C Supported Icon 1.1 (Re): All code shall conform to ISO 9899:1990 "Programming languages - C", amended and corrected by ISO/IEC 9899/COR1:1995, ISO/IEC 9899/AMD1:1995, and ISO/IEC 9899/COR2:1996.

MISRA C Non Supported Icon 1.2 (Re-): No reliance shall be placed on undefined or unspecified behavior.

MISRA C Non Supported Icon 1.3 (Re-): Multiple compilers and/or languages shall only be used if there is a common defined interface standard for object code to which the languages/compilers/assemblers conform.

MISRA C Non Supported Icon 1.4 (Re-): The compiler/linker shall be checked to ensure that 31 character significance and case sensitivity are supported for external identifiers.

MISRA C Non Supported Icon 1.5 (Ad-): Floating-point implementations should comply with a defined floating-point standard.

Language extensions

MISRA C Supported Icon 2.1 (Re): Assembly language shall be encapsulated and isolated.

MISRA C Supported Icon 2.2 (Re): Source code shall only use /* ... */ style comments.

MISRA C Supported Icon 2.3 (Re): The character sequence /* shall not be used within a comment.

MISRA C Non Supported Icon 2.4 (Ad-): Sections of code should not be 'commented out'.

Documentation

MISRA C Non Supported Icon 3.1 (Re-): All usage of implementation-defined behavior shall be documented.

MISRA C Non Supported Icon 3.2 (Re-): The character set and the corresponding encoding shall be documented.

MISRA C Non Supported Icon 3.3 (Ad-): The implementation of integer division in the chosen compiler should be determined, documented and taken into account.

MISRA C Supported Icon 3.4 (Re): All uses of the #pragma directive shall be documented and explained.

MISRA C Non Supported Icon 3.5 (Re-): The implementation-defined behavior and packing of bitfields shall be documented if being relied upon.

MISRA C Non Supported Icon 3.6 (Re-): All libraries used in production code shall be written to comply with the provisions of this document, and shall have been subject to appropriate validation.

Character sets

MISRA C Supported Icon 4.1 (Re): Only those escape sequences that are defined in the ISO C standard shall be used.

MISRA C Supported Icon 4.2 (Re): Trigraphs shall not be used.

Identifiers

MISRA C Supported Icon 5.1 (Re): Identifiers (internal and external) shall not rely on the significance of more than 31 characters.

MISRA C Supported Icon 5.2 (Re): [...]: Identifiers in an inner scope shall not use the same name as an identifier in an outer scope, and therefore hide that identifier.

MISRA C Non Supported Icon 5.3 (Re-): A 'typedef' name shall be a unique identifier.

MISRA C Supported Icon 5.4 (Re): A tag name shall be a unique identifier.

MISRA C Non Supported Icon 5.5 (Ad-): No object or function identifier with static storage duration should be reused.

MISRA C Non Supported Icon 5.6 (Ad-): No identifier in one name space should have the same spelling as an identifier in another name space, with the exception of structure and union member names.

MISRA C Non Supported Icon 5.7 (Ad-): No identifier name should be reused.

Types

MISRA C Non Supported Icon 6.1 (Re-): The plain char type shall be used only for storage and use of character values.

MISRA C Non Supported Icon 6.2 (Re-): 'signed' and 'unsigned' char type shall be used only for the storage and use of numeric values.

MISRA C Supported Icon 6.3 (Ad): 'typedefs' that indicate size and signedness should be used in place of the basic types.

MISRA C Supported Icon 6.4 (Re): Bit fields shall only be defined to be of type 'unsigned int' or 'signed int'.

MISRA C Non Supported Icon 6.5 (Re-): Bit fields of type signed int shall be at least 2 bits long.

Constants

MISRA C Supported Icon 7.1 (Re): Octal constants (other than zero) and octal escape sequences shall not be used.

Declarations and definitions

MISRA C Non Supported Icon 8.1 (Re-): Functions shall have prototype declarations and the prototype shall be visible at both the function definition and call.

MISRA C Supported Icon 8.2 (Re): Whenever an object or function is declared or defined, its type shall be explicitly stated.

MISRA C Non Supported Icon 8.3 (Re-): For each function parameter the type given in the declaration and definition shall be identical, and the return types shall also be identical.

MISRA C Supported Icon 8.4 (Re): [...]: If objects or functions are declared more than once their types shall be compatible.

MISRA C Non Supported Icon 8.5 (Re-): There shall be no definitions of objects or functions in a header file.

MISRA C Supported Icon 8.6 (Ad): Functions shall be declared at file scope.

MISRA C Supported Icon 8.7 (Re): Objects [...] shall be defined at block scope if they are only accessed from within a single function [...].

MISRA C Supported Icon 8.8 (Re): [...]: An external object or function shall be declared in one and only one file.

MISRA C Supported Icon 8.9 (Re): [...]: An identifier with external linkage shall have exactly one external definition.

MISRA C Supported Icon 8.10 (Re): [...]: All declarations and definitions of objects or functions at file scope shall have internal linkage unless external linkage is required.

MISRA C Supported Icon 8.11 (Re): The static storage class specifier shall be used in definitions and declarations of objects and functions that have internal linkage.

MISRA C Supported Icon 8.12 (Re): When an array is declared with external linkage, its size shall be stated explicitly or defined implicitly by initialization.

Initialisation

MISRA C Non Supported Icon 9.1 (Re-): All automatic variables shall have been assigned a value before being used.

MISRA C Non Supported Icon 9.2 (Re-): Braces shall be used to indicate and match the structure in the non-zero initialization of arrays and structures.

MISRA C Supported Icon 9.3 (Re): In an enumerator list, the '=' construct shall not be used to explicitly initialize members other than the first, unless all items are explicitly initialized.

Arithmetic type conversion

MISRA C Non Supported Icon 10.1 (Re-): The value of an expression of integer type shall not be implicitly converted to a different underlying type if: a) it is not a conversion to a wider integer type of the same signedness, or b) the expression is complex, or c) the expression is not constant and is a function argument, or d) the expression is not constant and is a return expression.

MISRA C Non Supported Icon 10.2 (Re-): The value of an expression of floating type shall not be implicitly converted to a different type if: a) it is not a conversion to a wider floating type, or b) the expression is complex, or c) the expression is a function argument, or d) the expression is a return expression.

MISRA C Supported Icon 10.3 (Re): The value of a complex expression of integer type may only be cast to a type that is narrower and of the same signedness as the underlying type of the expression.

MISRA C Non Supported Icon 10.4 (Re-): The value of a complex expression of floating type may only be cast to a narrower floating type.

MISRA C Non Supported Icon 10.5 (Re-): If the bitwise operators ~ and << are applied to an operand of underlying type 'unsigned char' or 'unsigned short', the result shall be immediately cast to the underlying type of the operand.

MISRA C Supported Icon 10.6 (Re): A 'U' suffix shall be applied to all constants of 'unsigned' type.

Pointer type conversion

MISRA C Non Supported Icon 11.1 (Re-): Conversions shall not be performed between a pointer to a function and any type other than an integral type.

MISRA C Non Supported Icon 11.2 (Re-): Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to object type or a pointer to void.

MISRA C Non Supported Icon 11.3 (Ad-): A cast should not be performed between a pointer type and an integral type.

MISRA C Non Supported Icon 11.4 (Ad-): A cast should not be performed between a pointer to object type and a different pointer to object type.

MISRA C Non Supported Icon 11.5 (Re-): A cast shall not be performed that removes any 'const' or 'volatile' qualification from the type addressed by a pointer.

Expressions

MISRA C Non Supported Icon 12.1 (Ad-): Limited dependence should be placed on C's operator precedence rules in expressions.

MISRA C Supported Icon 12.2 (Re): The value of an expression shall be the same under any order of evaluation that the standard permits.

MISRA C Supported Icon 12.3 (Re): The 'sizeof' operator shall not be used on expressions that contain side effects.

MISRA C Supported Icon 12.4 (Re): The right-hand operand of a logical && or || operator shall not contain side effects.

MISRA C Supported Icon 12.5 (Re): The operands of a logical && or || shall be 'primary-expressions'.

MISRA C Supported Icon 12.6 (Ad): The operands of logical operators (&&, || and !) should be effectively Boolean. Expressions that are effectively Boolean should not be used as operands to operators other than (&&, || and !).

MISRA C Supported Icon 12.7 (Re): Bitwise operators shall not be applied to operands whose underlying type is signed.

MISRA C Non Supported Icon 12.8 (Re-): The right-hand operand of a shift operator shall lie between zero and one less than the width in bits of the underlying type of the left-hand operand.

MISRA C Supported Icon 12.9 (Re): The unary minus operator shall not be applied to an expression whose underlying type is unsigned.

MISRA C Supported Icon 12.10 (Re): The comma operator shall not be used.

MISRA C Non Supported Icon 12.11 (Ad-): Evaluation of constant unsigned integer expressions should not lead to wrap-around.

MISRA C Non Supported Icon 12.12 (Re-): The underlying bit representations of floating-point values shall not be used.

MISRA C Supported Icon 12.13 (Ad): The increment (++) and decrement (--) operators should not be mixed with other operators in an expression.

Control statement expressions

MISRA C Supported Icon 13.1 (Re): Assignment operators shall not be used in expressions that yield a Boolean value.

MISRA C Supported Icon 13.2 (Ad): Tests of a value against zero should be made explicit, unless the operand is effectively - Boolean.

MISRA C Supported Icon 13.3 (Re): Floating-point expressions shall not be tested for equality or inequality.

MISRA C Supported Icon 13.4 (Re): The controlling expression of a 'for' statement shall not contain any objects of floating type.

MISRA C Non Supported Icon 13.5 (Re-): The three expressions of a 'for' statement shall be concerned only with loop control.

MISRA C Non Supported Icon 13.6 (Re-): Numeric variables being used within a 'for' loop for iteration counting shall not be modified in the body of the loop.

MISRA C Non Supported Icon 13.7 (Re-): Boolean operations whose results are invariant shall not be permitted.

Control flow

MISRA C Non Supported Icon 14.1 (Re-): There shall be no unreachable code.

MISRA C Supported Icon 14.2 (Re): All non-null statements shall either: a) have at least one side effect however executed, or b) cause control flow to change.

MISRA C Non Supported Icon 14.3 (Re-): Before preprocessing, a null statement shall only occur on a line by itself;, it may be followed by a comment provided that the first character following the null statement is a white-space character.

MISRA C Supported Icon 14.4 (Re): The 'goto' statement shall not be used.

MISRA C Supported Icon 14.5 (Re): The 'continue' statement shall not be used.

MISRA C Supported Icon 14.6 (Re): For any iteration statement there shall be at most one break statement used for loop termination.

MISRA C Supported Icon 14.7 (Re): A function shall have a single point of exit at the end of the function.

MISRA C Supported Icon 14.8 (Re): The statement forming the body of a 'switch', 'while', 'do ... while' or 'for' statement be a compound statement.

MISRA C Supported Icon 14.9 (Re): An 'if-expression' construct shall be followed by a compound statement. The 'else' keyword shall be followed by either a compound statement, or another 'if' statement.

MISRA C Supported Icon 14.10 (Re): All 'if ... else if' constructs shall be terminated with an 'else' clause.

Switch statements

MISRA C Non Supported Icon 15.1 (Re-): A 'switch' label shall only be used when the most closely-enclosing compound statement is the body of a 'switch' statement.

MISRA C Supported Icon 15.2 (Re): An unconditional 'break' statement shall terminate every non-empty 'switch' clause.

MISRA C Supported Icon 15.3 (Re): The final clause of a 'switch' statement shall be the 'default' clause.

MISRA C Supported Icon 15.4 (Re): A 'switch' expression shall not represent a value that is effectively Boolean.

MISRA C Supported Icon 15.5 (Re): Every 'switch' statement shall have at least one 'case' clause.

Functions

MISRA C Supported Icon 16.1 (Re): Functions shall not be defined with variable numbers of arguments.

MISRA C Supported Icon 16.2 (Re): Functions shall not call themselves, either directly or indirectly.

MISRA C Supported Icon 16.3 (Re): Identifiers shall be given for all of the parameters in a function prototype declaration.

MISRA C Non Supported Icon 16.4 (Re-): The identifiers used in the declaration and definition of a function shall be identical.

MISRA C Supported Icon 16.5 (Re): Functions with no parameters shall be declared with parameter type void.

MISRA C Supported Icon 16.6 (Re): The number of arguments passed to a function shall match the number of parameters.

MISRA C Non Supported Icon 16.7 (Ad-): A pointer parameter in a function prototype should be declared as 'pointer to const' if the pointer is not used to modify the addressed object.

MISRA C Supported Icon 16.8 (Re): All exit paths from a function with non-void return type shall have an explicit 'return' statement with an expression.

MISRA C Supported Icon 16.9 (Re): A function identifier shall only be used with either a preceding '&', or with a parenthesised parameter list, which may be empty.

MISRA C Non Supported Icon 16.10 (Re-): If a function returns error information, then that error information shall be tested.

Pointers and arrays

MISRA C Non Supported Icon 17.1 (Re-): Pointer arithmetic shall only be applied to pointers that address an array or array element.

MISRA C Supported Icon 17.2 (Re): Pointer subtraction shall only be applied to pointers that address elements of the same array.

MISRA C Non Supported Icon 17.3 (Re-): >, >=, <, <= shall not be applied to pointer types except where they point to the same array.

MISRA C Supported Icon 17.4 (Re): Array indexing shall be the only allowed form of pointer arithmetic.

MISRA C Supported Icon 17.5 (Ad): The declaration of objects should contain no more than 2 levels of pointer indirection.

MISRA C Supported Icon 17.6 (Re): The address of an object with automatic storage shall not be assigned to another object that may persist after the first object has ceased to exist.

Structures and unions

MISRA C Supported Icon 18.1 (Re): [...]: All structure or union types shall be complete at the end of a translation unit.

MISRA C Non Supported Icon 18.2 (Re-): An object shall not be assigned to an overlapping object.

MISRA C Non Supported Icon 18.3 (Re-): An area of memory shall not be reused for unrelated purposes.

MISRA C Supported Icon 18.4 (Re): Unions shall not be used.

Preprocessinf directives

MISRA C Non Supported Icon 19.1 (Ad-): '#include' statements in a file should only be preceded by other preprocessor directives or comments.

MISRA C Supported Icon 19.2 (Ad): Non-standard characters should not occur in header file names in include directives.

MISRA C Supported Icon 19.3 (Re): The '#include' directive shall be followed by either a <filename> or \"filename\" sequence.

MISRA C Non Supported Icon 19.4 (Re-): C macros shall only expand to a braced initialized, a constant, a parenthesized expression, a type qualifier, a storage class specifier, or a do-while-zero construct.

MISRA C Supported Icon 19.5 (Re): Macros shall not be '#define'd or '#undef'd within a block.

MISRA C Supported Icon 19.6 (Re): '#undef' shall not be used.

MISRA C Supported Icon 19.7 (Ad): A function should be used in preference to a function-like macro.

MISRA C Supported Icon 19.8 (Re): A function-like macro shall not be invoked without all of its arguments.

MISRA C Supported Icon 19.9 (Re): Arguments to a function-like macro shall not contain tokens that look like preprocessing directives.

MISRA C Supported Icon 19.10 (Re): In the definition of a function-like macro each instance of a parameter shall be enclosed in parentheses unless it is used as the operand of # or ##.

MISRA C Supported Icon 19.11 (Re): All macro identifiers in preprocessor directives shall be defined before use, except in '#ifdef' and '#ifndef' preprocessor directives and the 'defined()' operator.

MISRA C Supported Icon 19.12 (Re): There shall be at most one occurrence of the # or ## preprocessor operators in a single macro definition.

MISRA C Supported Icon 19.13 (Ad): The # and ## preprocessor operators should not be used.

MISRA C Supported Icon 19.14 (Re): The 'defined' preprocessor operator shall only be used in one of the two standard forms.

MISRA C Supported Icon 19.15 (Re): Precautions shall be taken in order to prevent the contents of a header tile being included twice.

MISRA C Supported Icon 19.16 (Re): Preprocessing directives shall be syntactically meaningful even when excluded by the preprocessor.

MISRA C Supported Icon 19.17 (Re): All '#else', '#elif' and '#endif' preprocessor directives shall reside in the same file as the '#if' or '#ifdef' directive to which they are related.

Standard libraries

MISRA C Supported Icon 20.1 (Re): [...]: Reserved identifiers, macros and functions in the standard library, shall not be defined, redefined or undefined.

MISRA C Supported Icon 20.2 (Re): [...]: The names of standard library macros, objects and functions shall not be reused.

MISRA C Non Supported Icon 20.3 (Re-): The validity of values passed to library functions shall be checked.

MISRA C Supported Icon 20.4 (Re): Dynamic heap memory allocation shall not be used.

MISRA C Supported Icon 20.5 (Re): The error indicator 'errno' shall not be used.

MISRA C Supported Icon 20.6 (Re): The macro 'offsetof', in library <stddef.h>, shall not be used.

MISRA C Supported Icon 20.7 (Re): The 'setjmp' macro and the 'longjmp' function shall not be used.

MISRA C Supported Icon 20.8 (Re): The signal handling facilities of <signal.h> shall not be used.

MISRA C Supported Icon 20.9 (Re): The input/output library <stdio.h> shall not be used in production code.

MISRA C Supported Icon 20.10 (Re): The library functions 'atof', 'atoi' and 'atol' from library <stdlib.h> shall not be used.

MISRA C Supported Icon 20.11 (Re): The library functions 'abort', 'exit', 'getenv' and 'system' from library <stdlib.h> shall not be used.

MISRA C Supported Icon 20.12 (Re): The time handling functions of library <time.h> shall not be used.

Run-time failures

MISRA C Non Supported Icon 21.1 (Re-): Minimization of run-time failures shall be ensured by the use of at least one of: 

a) static analysis tools/techniques;
b) dynamic analysis tools/techniques;
c) explicit coding of checks to handle run-time faults.

Percentage of MISRA C:2004 Compliance Matrix Support in DA-C

Number of Rules: 141
Number of Required Rules: 120
Number of Advisory Rules: 21

Category

Number of Rules
141

Number of Required Rules
120

Number of Advisory Rules
21

MISRA C Supported Icon Fully supported

89
63%

80
67%

9
42%

MISRA C Non Supported Icon Not supported

52
37%

40
33%

12
58%