CodeCheck Documentation
CodeCheck Documentation - MISRA C 2012

Standard: MISRA C 2012

The The Motor Industry Software Reliability Association (MISRA) guidelines for C published in 2012

MISRA Mission Statement: To provide assistance to the automotive industry in the application and creation within vehicle systems of safe and reliable software.

MISRA, The Motor Industry Software Reliability Association, is a collaboration between vehicle manufacturers, component suppliers and engineering consultancies which seeks to promote best practice in developing safety-related electronic systems in road vehicles and other embedded systems. To this end MISRA publishes documents that provide accessible information for engineers and management, and holds events to permit the exchange of experiences between practitioners.

The first edition of the MISRA C Standard was published in 1998, the second edition was released in 2004 with many substantial changes, and the third was released in 2012 with many more changes.

www.misra.org.uk

© MIRA Limited, 2004, 2008, 2012.

All RulesAdvisory RulesMandatory RulesRequired Rules
Understand % Coverage76%73%44%79%
Understand Coverage12127489
Total Rules159379112
Check IDCheck NameSupportedCategory
MISRA12_1.11.1 The program shall contain no violations of the standard C syntax and constraints, and shall not exceed the implementation's translation limitsYesRequired
MISRA12_1.21.2 Language extensions should not be usedNoAdvisory
MISRA12_1.31.3 There shall be no occurrence of undefined or critical unspecified behaviourNoRequired
MISRA12_2.12.1 A project shall not contain unreachable codeYesRequired
MISRA12_2.22.2 There shall be no dead codeNoRequired
MISRA12_2.32.3 A project should not contain unused type declarationsYesAdvisory
MISRA12_2.42.4 A project should not contain unused tag declarationsYesAdvisory
MISRA12_2.52.5 A project should not contain unused macro declarationsYesAdvisory
MISRA12_2.62.6 Unused LabelsYesRequired
MISRA12_2.72.7 There should be no unused parameters in functionsYesAdvisory
MISRA12_3.13.1 The character sequences /* and // shall not be used within a commentYesRequired
MISRA12_3.23.2 Line-splicing shall not be used in // commentsYesRequired
MISRA12_4.14.1 Octal and Hexadecimal SequencesYesRequired
MISRA12_4.24.2 Trigraphs should not be usedYesAdvisory
MISRA12_5.15.1 External identifiers shall be distinctYesRequired
MISRA12_5.25.2 Identifiers declared in the same scope and name space shall be distinctYesRequired
MISRA12_5.35.3 Shadowed IdentifiersYesRequired
MISRA12_5.45.4 Macro identifiers shall be distinctYesRequired
MISRA12_5.55.5 Identifiers shall be distinct from macro namesYesRequired
MISRA12_5.65.6 A typedef name shall be a unique identifierYesRequired
MISRA12_5.75.7 A tag name shall be a unique identifierYesRequired
MISRA12_5.85.8 Identifiers that define objects or functions with external linkage shall be uniqueYesRequired
MISRA12_5.95.9 Identifiers that define objects or functions with internal linkage should be uniqueYesAdvisory
MISRA12_6.16.1 Bit-fields shall only be declared with an appropriate typeYesRequired
MISRA12_6.26.2 Single-bit named bit fields shall not be of a signed typeYesRequired
MISRA12_7.17.1 Octal constants shall not be usedYesRequired
MISRA12_7.27.2 A u or U suffix shall be applied to all integer constants that are represented in an unsigned typeYesRequired
MISRA12_7.37.3 The lowercase character L shall not be used in a literal suffixYesRequired
MISRA12_7.47.4 A string literal shall not be assigned to an object unless the object's type is "pointer to const-qualified char"NoRequired
MISRA12_8.18.1 Types shall be explicitly specifiedYesRequired
MISRA12_8.28.2 Use Named Parameters and Prototype FormYes
MISRA12_8.38.3 All declarations of an object or function shall use the same names and type qualifiersYesRequired
MISRA12_8.48.4 A compatible declaration shall be visible when an object or function with external linkage is definedYesRequired
MISRA12_8.58.5 An external object or function shall be declared once in one and only one fileYesRequired
MISRA12_8.68.6 An identifier with external linkage shall have exactly one external definitionYesRequired
MISRA12_8.78.7 Functions and objects should not be defined with external linkage if they are referenced in only one translation unitYesAdvisory
MISRA12_8.88.8 Use the static keyword for internal linkageYesRequired
MISRA12_8.98.9 Objects shall be local if only accessed from one functionYesAdvisory
MISRA12_8.108.10 Non-static Inline FunctionsYesRequired
MISRA12_8.118.11 When an array with external linkage is declared, its size should be explicitly specifiedYesAdvisory
MISRA12_8.128.12 Within an enumerator list, the value of an implicitly-specified enumeration constant shall be uniqueYesRequired
MISRA12_8.138.13 A pointer should point to a const-qualified type whenever possibleNoAdvisory
MISRA12_8.148.14 The restrict type qualifier shall not be usedYesRequired
MISRA12_9.19.1 The value of an object with automatic storage duration shall not be read before it has been setYesMandatory
MISRA12_9.29.2 The initializer for an aggregate or union shall be enclosed in bracesYesRequired
MISRA12_9.39.3 Arrays shall not be partially initializedYesRequired
MISRA12_9.49.4 An element of an object shall not be initialized more than onceYesRequired
MISRA12_9.59.5 Where designated initializers are used to initialize an array object the size of the array shall be specified explicitlyYesRequired
MISRA12_10.110.1 Operands shall not be of an inappropriate essential typeYesRequired
MISRA12_10.210.2 Expressions of essentially character type shall not be used inappropriately in addition and subtraction operationsNoRequired
MISRA12_10.310.3 The value of an expression shall not be assigned to an object with a narrower essential type or of a different essential type categoryNoRequired
MISRA12_10.410.4 Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type categoryYesRequired
MISRA12_10.510.5 The value of an expression should not be cast to an inappropriate essential typeYesAdvisory
MISRA12_10.610.6 The value of a composite expression shall not be assigned to an object with
wider essential type
YesRequired
MISRA12_10.710.7 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 typeNoRequired
MISRA12_10.810.8 The value of a composite expression shall not be cast to a different essential type category or a wider essential typeYesRequired
MISRA12_11.111.1 Conversions shall not be performed between a pointer to a function and any other typeYesRequired
MISRA12_11.211.2 Conversions shall not be performed between a pointer to an incomplete type
and any other type
YesRequired
MISRA12_11.311.3 A cast shall not be performed between a pointer to object type and a pointer to a different object typeYesRequired
MISRA12_11.411.4 A conversion should not be performed between a pointer to object and an integer typeYesRequired
MISRA12_11.511.5 A conversion should not be performed from pointer to void into pointer to objectYesAdvisory
MISRA12_11.611.6 A cast shall not be performed between pointer to void and an arithmetic typeYesRequired
MISRA12_11.711.7 A cast shall not be performed between pointer to object and a non-integer arithmetic typeYesRequired
MISRA12_11.811.8 A cast shall not remove any const or volatile qualification from the type pointed to by a pointerYesRequired
MISRA12_11.911.9 The macro NULL shall be the only permitted form of integer null pointer constantYesRequired
MISRA12_12.112.1 The precedence of operators within expressions should be made explicitNoAdvisory
MISRA12_12.212.2 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.YesRequired
MISRA12_12.312.3 The comma operator shall not be used.YesAdvisory
MISRA12_12.412.4 Evaluation of constant expressions should not lead to unsigned integer wrap-aroundNoAdvisory
MISRA12_13.113.1 Initializer lists shall not contain persistent side effectsYesRequired
MISRA12_13.213.2 The value of an expression and its persistent side effects shall be the same under all permitted evaluation ordersNoRequired
MISRA12_13.313.3 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 operatorYesAdvisory
MISRA12_13.413.4 The result of an assignment operator should not be usedYesAdvisory
MISRA12_13.513.5 The right hand operand of a logical && or || operator shall not contain persistent side effectsYesRequired
MISRA12_13.613.6 The operand of the sizeof operator shall not contain any expression which has potential side effectsYesMandatory
MISRA12_14.114.1 A loop counter shall not have essentially floating typeYesRequired
MISRA12_14.214.2 A for loop shall be well-formedNoRequired
MISRA12_14.314.3 Controlling expressions shall not be invariantNoRequired
MISRA12_14.414.4 The controlling expression of an if statement and the controlling expression of an iteration-statement shall have essentially Boolean typeYesRequired
MISRA12_15.115.1 The goto statement should not be usedYesAdvisory
MISRA12_15.215.2 The goto statement shall jump to a label declared later in the same functionYesRequired
MISRA12_15.315.3 Any label referenced by a goto statement shall be declared in the same block, or in any block enclosing the goto statementYesRequired
MISRA12_15.415.4 There should be no more than one break or goto statement used to terminate any iteration statementYesAdvisory
MISRA12_15.515.5 A function should have a single point of exit at the endYesAdvisory
MISRA12_15.615.6 The body of an iteration-statement or a selection-statement shall be a compound-statement YesRequired
MISRA12_15.715.7 All if ... else if constructs shall be terminated with an else statementYesRequired
MISRA12_16.1Switch Statement not Well-formedYesRequired
MISRA12_16.216.2 A switch label shall only be used when the most closely-enclosing compound statement is the body of a switch statementYesRequired
MISRA12_16.316.3 An unconditional break statement shall terminate every switch-clauseYesRequired
MISRA12_16.416.4 Every switch statement shall have a default labelYesRequired
MISRA12_16.516.5 A default label shall appear as either the first or the last switch label of a switch statementYesRequired
MISRA12_16.616.6 Every switch statement shall have at least two switch-clausesYesRequired
MISRA12_16.716.7 A switch-expression shall not have essentially Boolean typeNoRequired
MISRA12_17.117.1 The features of <stdarg.h> shall not be usedYesRequired
MISRA12_17.217.2 Functions shall not call themselves, either directly or indirectlyYesRequired
MISRA12_17.317.3 A function shall not be declared implicitlyYesMandatory
MISRA12_17.417.4 Always return a value in non-void functionsYesRequired
MISRA12_17.517.5 The function argument corresponding to a parameter declared to have an array type shall have an appropriate number of elementsNoAdvisory
MISRA12_17.617.6 The declaration of an array parameter shall not contain the static keyword between the [ ]YesMandatory
MISRA12_17.717.7 The value returned by a function having non-void return type shall be usedYesRequired
MISRA12_17.817.8 A function parameter should not be modifiedYesAdvisory
MISRA12_18.118.1 A pointer resulting from arithmetic on a pointer operand shall addressNoRequired
MISRA12_18.218.2 Subtraction between pointers shall only be applied to pointers that address elements of the same arrayYesRequired
MISRA12_18.318.3 The relational operators >, >=, < and <= shall not be applied to objects of pointer type except where they point into the same objectYesRequired
MISRA12_18.418.4 The +, -, += and -= operators should not be applied to an expression of pointer typeNoAdvisory
MISRA12_18.518.5 Declarations should contain no more than two levels of pointer nestingNoAdvisory
MISRA12_18.618.6 The address of an object with automatic storage shall not be copied to another object that persists after the first object has ceased to existYesRequired
MISRA12_18.718.7 Flexible array members shall not be declaredYesRequired
MISRA12_18.818.8 Variable-length array types shall not be usedNoRequired
MISRA12_19.119.1 An object shall not be assigned or copied to an overlapping objectNoMandatory
MISRA12_19.219.2 The Union keyword should not be usedYesAdvisory
MISRA12_20.120.1 #include directives should only be preceded by preprocessor directives or commentsYesAdvisory
MISRA12_20.220.2 The ', " or backslash characters and the /* or // character sequences shall not occur in a header file nameYesRequired
MISRA12_20.320.3 The #include directive shall be followed by either a <filename> or "filename" sequenceYesRequired
MISRA12_20.420.4 A macro shall not be defined with the same name as a keywordYesRequired
MISRA12_20.520.5 #undef should not be usedYesAdvisory
MISRA12_20.620.6 Tokens that look like a preprocessing directive shall not occur within a macro argumentYesRequired
MISRA12_20.720.7 Expressions resulting from the expansion of macro parameters shall be enclosed in parenthesesNoRequired
MISRA12_20.820.8 The controlling expression of a #if or #elif preprocessing directive shall evaluate to 0 or 1NoRequired
MISRA12_20.920.9 All identifiers used in the controlling expression of #if or #elif preprocessing directives shall be #define'd before evaluationNoRequired
MISRA12_20.1020.10 The # and ## operators should not be usedYesAdvisory
MISRA12_20.1120.11 A macro parameter immediately following a # operator shall not immediately be followed by a ## operatorYesRequired
MISRA12_20.1220.12 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 operatorsNoRequired
MISRA12_20.1320.13 Invalid Preprocessor DirectivesYesRequired
MISRA12_20.1420.14 All #else, #elif and #endif preprocessor directives shall reside in the same file as the #if, #ifdef or #ifndef directive to which they are relatedYesRequired
MISRA12_21.121.1 #define and #undef shall not be used on a reserved identifier or reserved macro nameYesRequired
MISRA12_21.221.2 Reserved Identifiers or MacrosYesRequired
MISRA12_21.321.3 The memory allocation and deallocation functions of &lt;stdlib.h&gt; shall not be usedYesRequired
MISRA12_21.421.4 The standard header file <setjmp.h> shall not be usedYesRequired
MISRA12_21.521.5 The standard header file signal.h shall not be usedYesRequired
MISRA12_21.621.6 The Standard Library input/output functions shall not be usedYesRequired
MISRA12_21.721.7 The atof, atoi, atol and atoll functions of <stdlib.h> shall not be usedYesRequired
MISRA12_21.821.8 The library functions abort, exit, getenv and system of <stdlib.h> shall not be usedYesRequired
MISRA12_21.921.9 The library functions bsearch and qsort of <stdlib.h> shall not be usedYesRequired
MISRA12_21.1021.10 The Standard Library time and date functions shall not be usedYesRequired
MISRA12_21.1121.11 The standard header file <tgmath.h> shall not be usedYesRequired
MISRA12_21.1221.12 The exception handling features of <fenv.h> should not be usedYesAdvisory
MISRA12_22.122.1 All resources obtained dynamically by means of Standard Library functions shall be explicitly releasedNoRequired
MISRA12_22.222.2 A block of memory shall only be freed if it was allocated by means of a Standard Library functionNoMandatory
MISRA12_22.322.3 The same file shall not be open for read and write access at the same time on different streamsNoRequired
MISRA12_22.422.4 There shall be no attempt to write to a stream which has been opened as read-onlyNoMandatory
MISRA12_22.522.5 A pointer to a FILE object shall not be dereferencedNoMandatory
MISRA12_22.622.6 The value of a pointer to a FILE shall not be used after the associated stream has been closedNoMandatory
MISRA12_DIR_1.1Directive 1.1 Any implementation-defined behaviour on which the output of the program depends shall be documented and understoodNoRequired
MISRA12_DIR_2.1Directive 2.1 All source files shall compile without any compilation errorsYesRequired
MISRA12_DIR_3.1Directive 3.1 All code shall be traceable to documented requirementsNoRequired
MISRA12_DIR_4.1Directive 4.1 Run-time failures shall be minimizedNoRequired
MISRA12_DIR_4.2Directive 4.2 All usage of assembly language should be documentedNoAdvisory
MISRA12_DIR_4.3Directive 4.3 Assembly language shall be encapsulated and isolated.YesRequired
MISRA12_DIR_4.4Directive 4.4 Sections of code should not be "commented out"YesAdvisory
MISRA12_DIR_4.5Directive 4.5 Identifiers in the same name space with overlapping visibility should be typographically unambiguousYesAdvisory
MISRA12_DIR_4.6Directive 4.6 Typedefs that indicate size and signedness should be used in place of the basic numerical typesYesAdvisory
MISRA12_DIR_4.7Directive 4.7 If a function generates error information, then that error information shall be testedNoRequired
MISRA12_DIR_4.8Directive 4.8 If a pointer to a structure or union is never dereferenced within a translation unit, then the implementation of the object should be hiddenYesAdvisory
MISRA12_DIR_4.9Directive 4.9 A function should be used in preference to a function-like macro where they are interchangeableNoAdvisory
MISRA12_DIR_4.10Directive 4.10 Precautions shall be taken in order to prevent the contents of a header file being included more than onceYesRequired
MISRA12_DIR_4.11Directive 4.11 The validity of values passed to library functions shall be checkedNoRequired
MISRA12_DIR_4.12Directive 4.12 Dynamic memory allocation shall not be usedYesRequired
MISRA12_DIR_4.13Directive 4.13 Functions which are designed to provide operations on a resource should be called in an appropriate sequenceNoAdvisory