MISRA-C:2012 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, March 2013, The Motor Industry Software Reliability Association, Watling Street, Nuneaton, Warwickshire CV10 OTU, www.misra.org.uk

Rules are classified by MISRA as either mandatory Ma, 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 Ma/Re/Ad) nearly full supported Ma/Re/Ad with Note, or either not statically checkable or not supported in DAC V4.x (Ma-/Re-/Ad-) Current list of unsupported rules can also be viewed in the "Options > Static Code Analyzer".

Standard C environment

1.1 (Re-): The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limits. Note: Limited support in terms of covered cases will be added.

1.2 (Ad): Language extensions should not be used.

1.3 (Re-): There shall be no occurrence of undefined or critical unspecified behavior.

Unused code

2.1 (Re-): A project shall not contain unreachable code.

2.2 (Re-): There shall be no dead code.

2.3 (Ad): [...]: A project should not contain unused type declarations.

2.4 (Ad): [...]: A project should not contain unused tag declarations. Note: Usage of enum fields is not supported.

2.5 (Ad): [...]: A project should not contain unused macro declarations.

2.6 (Ad): [...]: A function should not contain unused label declarations.

2.7 (Ad): [...]: There should be no unused parameters in functions.

Comments

3.1 (Re): The character sequences /* and // shall not be used within a comment.

3.2 (Re): Line-splicing shall not be used in // comments.

Character and lexical conventions

4.1 (Re): Octal and hexadecimal escape sequences shall be terminated. Note: Multiple character constants are not supported.

4.2 (Ad): Trigraphs should not be used.

Identifiers

5.1 (Re-): External identifiers shall be distinct. Note: Full support will be added.

5.2 (Re-): Identifiers declared in the same scope and name space shall be distinct. Note: Full support will be added.

5.3 (Re): [...]: An identifier declared in an inner scope shall not hide an identifier declared in an outer scope.

5.4 (Re): Macro identifiers shall be distinct.

5.5 (Re): Identifiers shall be distinct from macro names.

5.6 (Re-): A typedef name [...] shall be a unique identifier. Note: Limited support in terms of covered cases will be added.

5.7 (Re): A tag name [...] shall be a unique identifier.

5.8 (Re): Identifiers that define objects or functions with external linkage shall be unique.

5.9 (Ad-): Identifiers that define objects or functions with internal linkage shall be unique. Note: Limited support in terms of covered cases will be added.

Types

6.1 (Re): Bit-fields shall only be declared with an appropriate type.

6.2 (Re-): Single-bit named bit fields shall not be of a signed type.

Literals and constants

7.1 (Re): Octal constants shall not be used.

7.2 (Re-): A u or U suffix shall be applied to all integer constants that are represented in an unsigned type. Note: Full support will be added.

7.3 (Re): The lowercase character l shall not be used in a literal suffix.

7.4 (Re-): A string literal shall not be assigned to an object unless the object's type is pointer to const-qualified char. Note: Full support will be added.

Declarations and definitions

8.1 (Re): Types shall be explicitly specified.

8.2 (Re): Function types shall be in prototype form with named parameters.

8.3 (Re-): All declarations of an object or function shall use the same names and type qualifiers.

8.4 (Re): [...]: A compatible declaration shall be visible when an object or function with external linkage is defined.

8.5 (Re): [...]: An external object or function shall be declared once in one and only one file. Note: Full support will be added.

8.6 (Re): [...]: An identifier with external linkage shall have exactly one external definition.

8.7 (Ad): [...]: Functions and objects should not be defined with external linkage if they are referenced in only one translation unit.

8.8 (Re): The static storage class specifier shall be used in all declarations of objects and functions that have internal linkage.

8.9 (Ad): An object [...] should be defined at block scope if its identifier only appears in a single function [...].

8.10 (Re-): An inline function shall be declared with the static storage class. Note: Full support will be added.

8.11 (Ad-): When an array with external linkage is declared, its size should be explicitly specified.

8.12 (Re-): Within an enumerator list, the value of an implicitly-specified enumeration constant shall be unique.

8.13 (Ad-): A pointer should point to a const-qualified type whenever possible.

8.14 (Re): The restrict type qualifier shall not be used.

Initialization

9.1 (Ma): The value of an object with automatic storage duration shall not be read before it has been set.

9.2 (Re-): The initializer for an aggregate or union shall be enclosed in braces.

9.3 (Re-): Arrays shall not be partially initialized.

9.4 (Re-): An element of an object shall not be initialized more than once.

9.5 (Re-): Where designated initializers are used to initialize an array object the size of the array shall be specified explicitly.

Essential type

10.1 (Re-): Operands shall not be of an inappropriate essential type. Note: Full support will be added.

10.2 (Re-): Expressions of essentially character type shall not be used inappropriately in addition and subtraction operations. Note: Full support will be added.

10.3 (Re-): The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type category. Note: Full support will be added.

10.4 (Re-): Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category. Note: Full support will be added.

10.5 (Ad-): The value of an expression should not be cast to an inappropriate essential type. Note: Full support will be added.

10.6 (Re-): The value of a composite expression shall not be assigned to an object with wider essential type. Note: Full support will be added.

10.7 (Re-): If a composite expression is used as one operand of an operator in which the usual arithmetic conversions are performed then the other operand shall not have wider essential type. Note: Full support will be added.

10.8 (Re-): The value of a composite expression shall not be cast to a different essential type category or a wider essential type. Note: Full support will be added.

Pointer type conversion

11.1 (Re): Conversions shall not be performed between a pointer to a function and any other type.

11.2 (Re): Conversions shall not be performed between a pointer to an incomplete type and any other type.

11.3 (Re): A cast shall not be performed between a pointer to object type and a pointer to a different object type.

11.4 (Ad): A conversion should not be performed between a pointer to object and an integer type.

11.5 (Ad): A conversion should not be performed from pointer to void into pointer to object.

11.6 (Re): A cast shall not be performed between pointer to void and an arithmetic type.

11.7 (Re): A cast shall not be performed between pointer to object and a non-integer arithmetic type.

11.8 (Re): A cast shall not remove any const or volatile qualification from the type pointed to by a pointer.

11.9 (Re-): The macro NULL shall be the only permitted form of integer null pointer constant. Note: Limited support in terms of covered cases will be added.

Expressions

12.1 (Ad-): The precedence of operators within expressions should be made explicit.

12.2 (Re-): The right hand operand of a shift operator shall lie in the range zero to one less than the width in bits of the essential type of the left hand operand. Note: Limited support will be added due to the fact that type sizes are not known for specific compilers.

12.3 (Ad): The comma operator should not be used.

12.4 (Ad-): Evaluation of constant expressions should not lead to unsigned integer wrap-around. Note: Limited support will be added due to the fact that type sizes are not known for specific compilers and analyzer limitations.

Side effects

13.1 (Re): Initializer lists shall not contain persistent side effects. Note: Function call in intializer list is considered to have side effect by default.

13.2 (Re): The value of an expression and its persistent side effects shall be the same under all permitted evaluation orders.

13.3 (Ad-): 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. Note: Limited support will be added.

13.4 (Ad): The result of an assignment operator should not be used.

13.5 (Re): The right hand operand of a logical && or || operator shall not contain persistent side effects.

13.6 (Ma): The operand of the sizeof operator shall not contain any expression which has potential side effects.

Control statement expressions

14.1 (Re): A loop counter shall not have essentially floating type.

14.2 (Re-): A for loop shall be well-formed. Note: Full support will be added.

14.3 (Re-): Controlling expressions shall not be invariant.

14.4 (Re): The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean type.

Control flow

15.1 (Ad): The goto statement should not be used.

15.2 (Re): The goto statement shall jump to a label declared later in the same function.

15.3 (Re-): Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statement. Note: Full support will be added.

15.4 (Ad-): There should be no more than one break or goto statement used to terminate any iteration statement. Note: Full support will be added.

15.5 (Ad): A function should have a single point of exit at the end.

15.6 (Re): The body of an iteration-statement or a selection-statement shall be a compound-statement.

15.7 (Re): All if ... else if constructs shall be terminated with an else statement.

Switch statements

16.1 (Re-): All switch statements shall be well-formed. Note: Full support will be added.

16.2 (Re-): A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statement. Note: Full support will be added.

16.3 (Re): An unconditional break statement shall terminate every switch-clause.

16.4 (Re): Every switch statement shall have a default label.

16.5 (Re-): A default label shall appear as either the first or the last switch label of a switch statement. Note: Full support will be added.

16.6 (Re-): Every switch statement shall have at least two switch clauses. Note: Full support will be added.

16.7 (Re): A switch-expression shall not have essentially Boolean type.

Functions

17.1 (Re): The features of <stdarg.h> shall not be used. Note: Reported at include directive.

17.2 (Re): Functions shall not call themselves, either directly or indirectly. Note: Indirect calls are not supported.

17.3 (Ma): A function shall not be declared implicitly.

17.4 (Ma): All exit paths from a function with non-void return type shall have an explicit return statement with an expression.

17.5 (Ad-): The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elements.

17.6 (Ma): The declaration of an array parameter shall not contain the static keyword between the [].

17.7 (Re-): The value returned by a function having non-void return type shall be used. Note: Full support will be added.

17.8 (Ad): A function parameter should not be modified.

Pointers and arrays

18.1 (Re-): A pointer resulting from arithmetic on a pointer operand shall address an element of the same array as that pointer operand.

18.2 (Re-): Subtraction between pointers shall only be applied to pointers that address elements of the same array.

18.3 (Re-): The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same object.

18.4 (Ad): The +, -, += and -= operators should not be applied to an expression of pointer type.

18.5 (Ad): Declarations should contain no more than two levels of pointer nesting. Note: Reported at usage, not the declaration.

18.6 (Re): The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to exist.

18.7 (Re): Flexible array members shall not be declared.

18.8 (Re-): Variable-length array types shall not be used.

Overlapping storage

19.1 (Ma-): An object shall not be assigned or copied to an overlapping object.

19.2 (Ad): The union keyword should not be used.

Preprocessing directives

20.1 (Ad-): #include directives should only be preceded by preprocessor directives or comments.

20.2 (Re): The ',  or \\ characters and the /* or // character sequences shall not occur in a header file name.

20.3 (Re): The #include directive shall be followed by either a <filename> or filename sequence.

20.4 (Re): A macro shall not be defined with the same name as a keyword.

20.5 (Ad): #undef should not be used.

20.6 (Re): Tokens that look like a preprocessing directive shall not occur within a macro argument.

20.7 (Re): Expressions resulting from the expansion of macro parameters shall be enclosed in parentheses.

20.8 (Re): The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1.

20.9 (Re): All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define'd before evaluation.

20.10 (Ad): The # and ## preprocessor operators should not be used.

20.11 (Re): A macro parameter immediately following a # operator shall not immediately be followed by a ## operator.

20.12 (Re-): A macro parameter used as an operand to the # or ## operators, which is itself subject to further macro replacement, shall only be used as an operand to these operators. Note: Full support will be added.

20.13 (Re): A line whose first token is # shall be a valid preprocessing directive.

20.14 (Re): All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are related.

Standard libraries

21.1 (Re): [...]: #define and #undef shall not be used on a reserved identifier or reserved macro name.

21.2 (Re): [...]: A reserved identifier or macro name shall not be declared.

21.3 (Re): The memory allocation and deallocation functions of <stdlib.h> shall not be used.

21.4 (Re): The standard header file <setjmp.h> shall not be used.

21.5 (Re): The standard header file <signal.h> shall not be used.

21.6 (Re): The Standard Library input/output functions shall not be used.

21.7 (Re): The atof, atoi, atol and atoll functions of <stdlib.h> shall not be used.

21.8 (Re): The library functions abort, exit, getenv and system of <stdlib.h> shall not be used.

21.9 (Re): The library functions bsearch and qsort of <stdlib.h> shall not be used.

21.10 (Re): The Standard Library time and date functions shall not be used.

21.11 (Re): The standard header file <tgmath.h> shall not be used.

21.12 (Ad): The exception handling features of <fenv.h> should not be used.

Resources

22.1 (Re-): All resources obtained dynamically by means of Standard Library functions shall be explicitly released.

22.2 (Ma-): A block of memory shall only be freed if it was allocated by means of a Standard Library function.

22.3 (Re-): The same file shall not be open for a read and write access at the same time on different streams.

22.4 (Ma-): There shall be no attempt to write to a stream which has been opened as read-only.

22.5 (Ma): [...]: A pointer to a FILE object shall not be dereferenced.

22.6 (Ma-): The value of a pointer to a FILE shall not be used after the associated stream has been closed.

Percentage of MISRA-C:2012 Compliance Matrix Support in DAC

Number of Rules (NoR): 143
Number of Mandatory Rules (NoMa): 10
Number of Required Rules (NoRe): 101
Number of Advisory Rules (NoAd): 32

Category

Number
of all rules
143

Number of 
Mandatory rules
10

Number of 
Required rules
101

Number of
Advisory rules
32

Cannot be checked automatically

8
5%

4

3

0

Fully supported

82 > 105
58% > 74%

6

56 > 79

20

Square yellow bomb icon Supported with some limitations

6
4%

0

4

2

Not supported

55 > 18
35% > 12%

0

38 > 8

10


Copyright 1993-2017, RistanCASE GmbH