MISRA C:1998 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, April 1998, 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 recommended (Rc). The succeeding sections list all rules along with support notes: whether the rule is fully supported (those rules are marked
), supported with specified limitations (
), or either not statically checkable or not supported in DA-C V4.0 (
)
Note: DA-C Static Code Analysis has been designed primarily to extract symbol usage information for cross referencing purposes. Therefore, it can infer the type of an expression or some part of it only if that type is directly derived from some symbol used in it. That includes e.g. (a), a.x, *a, a+b, a[2] and excludes e.g. func(), (x)?(y):(z) and so on.
Current list of unsupported rules can also be viewed in the "Options > Static Code Analyzer".
Environment
1 (Re) Do not use nonstandard language extensions.
2 (Rc) Other languages should only be used with an interface standard.
Note: Not statically checkable.
3 (Rc) Inline assembly is only allowed in dedicated C functions.
4 (Rc) Provision should be made for appropriate run-time checking.
Note: Not statically checkable.Character Sets
5 (Re) Use only characters defined by the C standard.
6 (Re) Numeric character values should be according to a subset of ISO 106460-1.
Note: Not statically checkable. ISO 10646-1 defines an international standard for mapping character sets to numeric values.
7 (Re) Do not use trigraphs.
8 (Re) Do not use wide characters and wide string literals.
Comments
9 (Re) Do not nest comments.
10 (Rc) Do not use comments to exclude code from compiling.
Identifiers
11 (Re) Identifiers should have at most 31 significant characters.
Note: DA-C analyses the source code and, of course, does not check whether a compiler/linker support 31 significant characters in identifiers.
12 (Rc) x: Do not use the same identifier in multiple name spaces.
Types
13 (Rc) Length-specific typedefs should be used instead of the basic types.
14 (Re) Use "
unsigned char
" or "signed char
" instead of plain "char
".
15 (Rc) Do not use nonstandard floating point arithmetic.
16 (Re) Do not rely on specific binary format for floating point numbers.
17 (Re) Do not reuse
typedef
names.Constants
18 (Rc) Always use type suffix for numeric constants.
19 (Re) Do not use octal numbers other than zero.
Declarations and Definitions
20 (Re) Always declare before use all variable and function identifiers.
21 (Re) x: Identifiers should not hide identifiers in an outer scope.
22 (Rc) x declaration should be at in function
y
and "static
".
23 (Rc) x: global declaration should be "
static
".
24 (Re) Identifiers shall not have both internal and external linkage.
25 (Re) x: Multiply defined identifier with external linkage.
26 (Re) x: Multiple declarations for objects or functions shall be compatible.
27 (Rc) x: External declared in more than one file.
28 (Rc) Do not use "
register
" specifier.
29 (Re) The use of a tag do not agree to declaration.
Note: Supported in type and variable declarations. Initializers are not checked whether they match the structure declared for tag.Initialization
30 (Re) All local variables shall be initialized before use.
31 (Re) Braces shall be used in the initialization of arrays and structures.
32 (Re) Only the first, or all enumeration constants may be initialized.
Operators
33 (Re) The right hand side of "
&&
" or "||
" should not contain side effects.
Note: The user-defined function call is always considered to have side effects.
34 (Re) The operands of "
&&
" or "||
" shall be primary expressions.
35 (Re) Do not use assignment operators in Boolean expressions.
36 (Rc) Logical operators should not be confused with bitwise operators.
37 (Re) Do not perform bitwise operations on signed integers.
See note.
38 (Re) A shift count shall be between 0 and the operand width minus 1.
39 (Re) Do not apply unary minus to an unsigned expression.
40 (Rc) Do not use "
sizeof
" on expressions with side effects.
Note: The user-defined function call is always considered to have side effects.
41 (Rc) The implementation of integer division should be documented.
42 (Re) The comma operator shall only be used in a "
for
" condition.Conversions
43 (Re) Do not use implicit conversions which may result in information loss.
Note: DA-C Static Code Analysis does not give this kind of information.
44 (Rc) Do not use redundant explicit casts.
See note.
45 (Re) Do not use type casting from any type to / from pointers.
See note.Expressions
46 (Re) The value of an expression shall be evaluation order independent.
47 (Rc) Do not rely on operator precedence rules, but use parenthesis.
48 (Rc) Use explicit casts for mixed arithmetic.
49 (Rc) Tests of a (non-Boolean) value against 0 should be made explicit.
50 (Re) Do not test floating point variables for exact equality or inequality.
See note.
51 (Rc) Constant unsigned integer expressions should not wrap-around.
Control flow
52 (Re) Unreachable code detected.
53 (Re) All non-null statements should have a side-effect.
Note: The user-defined function call is always considered to have side effects.
54 (Re) A null statement should only occur on a separate line.
55 (Rc) Do not use labels.
56 (Re) Do not use "
goto
" statement.
57 (Re) Do not use "
continue
" statement.
58 (Re) Do not use "
break
" statement, except in a "switch
".
59 (Re) An "
if
" or loop body shall always be enclosed in braces.
60 (Rc) All "
if
", "else if
" constructs should contain a final "else
".
61 (Re) Terminate every non-empty "
case
" clause with a "break
".
62 (Re) Always put a "
default
" case in a "switch
" statement.
63 (Rc) "
switch
" expression should not be of Boolean type.
64 (Re) "
switch
" statement with no "case
" statements.
65 (Re) Do not use floating point variable as loop counter.
See note.
66 (Rc) Use expressions in "
for
" only for loop control.
67 (Rc) Iterator variables should not be modified in a "
for
" loop.Functions
68 (Re) Always declare a function at file scope.
69 (Re) Do not use functions with variable number of arguments.
70 (Re) Functions should not call themselves.
Note: Only direct recursion is reported.
71 (Re) Function prototype should be visible at the definition and call.
72 (Re) Function prototype of the declaration shall match the definition.
73 (Re) Identifiers should be given for all prototype parameters or for none.
74 (Re) Parameter identifiers shall be identical for declaration/definition.
75 (Re) Function should have an explicit return type.
76 (Re) Functions with no parameters should have a "
void
" parameter list.
77 (Re) An actual parameter type should be compatible with the prototype.
78 (Re) x: The number of actual parameters should match the prototype.
79 (Re) The values returned by "
void
" functions should not be used.
80 (Re) "
void
" expressions should not be passed as function parameters.
81 (Rc) "
const
" should be used for reference parameters not modified.
82 (Rc) A function should have a single point of exit.
83 (Re) Every exit point shall have a "
return
" of the declared return type.
See note.
84 (Re) For "
void
" functions, "return
" should not have an expression.
85 (Rc) Use empty parenthesis to call functions with no parameters.
86 (Rc) If a function returns error information, it should be tested.
Preprocessing Directives
87 (Re)
#include
shall only be preceded by another directives or comments.
88 (Re) Non-standard characters are not allowed in
#include
directive.
89 (Re) Use either
<filename>
or\"filename\"
after#include
.
90 (Re) Plain macros shall only be used for constants/qualifiers/specifiers.
91 (Re) Do not
#define
/#undef
a macro within a block.
92 (Rc) Do not use "
#undef
".
93 (Rc) Use a function instead a macro.
94 (Re) x: A function-like macro shall not be used without all arguments.
95 (Re) Macro arguments should not contain pre-preprocessing directives.
96 (Re) Macro definitions / parameters should be enclosed in parentheses.
97 (Rc) x: The use in a pre-processing directive before definition.
98 (Re) A macro definition shall contain at most one
#
or##
operator.
99 (Re) All uses of the
#pragma
directive shall be documented.
100 (Re) Nonstandard use of operator "
defined
".Pointers and Arrays
101 (Rc) Do not use pointer arithmetic.
102 (Rc) Do not use more than double indirect pointers.
103 (Re) No relational operators between pointers to different objects.
104 (Re) Do not use non-constant pointers to functions.
105 (Re) x: should point to functions of identical type.
106 (Re) An automatic address may not be assigned to a longer lived object.
107 (Re) Do not dereference null pointer.
Note: Not statically checkable.Structures and Unions
108 (Re) x: All struct / union members shall be fully specified.
109 (Re) Do not use overlapping variable storage.
110 (Re) Do not use unions to access the sub-parts of larger types.
111 (Re) Bit fields shall have type "
unsigned
int" or "signed int
".
112 (Re) Make "signed int" bit fields at least 2 bits wide.
113 (Re) Do not use unnamed struct / union members.
Standard Libraries
114 (Re) x: Do not redefine reserved and standard library names.
115 (Re) x: Do not reuse standard library function names.
116 (Re) Production libraries shall comply with the MISRA C restriction.
Note: DA-C analyzes standard libraries headers and reports MISRA warnings for them if Options > Static Code Analyzer... / General / Warnings / Disabled for all headers and Options > Static Code Analyzer... / General / Warnings / Disabled for standard library headers are both unchecked.
117 (Re) Library function parameters should be checked.
Not statically checkable.
118 (Re) Do not use heap memory allocation.
119 (Re) "
errno
" should not be used.
120 (Re) Do not use "
offsetof
" macro.
121 (Re) Do not use
<locale.h>
and "setlocale
" function.
122 (Re) Do not use "
setjmp
" and "longjmp
" standard library functions.
123 (Re) Do not use the signal handling of
<signal.h>
.
124 (Re) Do not use
<stdio.h>
library.
125 (Re) Do not use
atof
/atoi
/atol
standard library functions.
126 (Re) Do not use
abort
/exit
/getenv
/system
standard library functions.
127 (Re) Do not use the time handling of
<time.h>
library.Percentage of MISRA C:1998 Compliance Matrix Support in DA-C
Number of Rules (NoR): 127
Number of Required Rules (NoRe): 93
Number of Recommendations (NoRc): 34
Category
NoR
127NoRe
93NoRc
34
Fully supported
76
60%59
64%17
50%
Supported with some limitations
16
13%13
14%3
9%
Cannot be statically checkable, or not supported
35
28%21
23%14
41%
Copyright © 1993-2022, RistanCASE PR